Skip to content

Instantly share code, notes, and snippets.

View fideloper's full-sized avatar
🏠
Working from home

Chris Fidao fideloper

🏠
Working from home
View GitHub Profile
@fideloper
fideloper / sample-app
Created May 15, 2013 20:02
Sample application Upstart script, using Forever
#!/bin/bash
# Sample App Init script for running sample app daemon
#
# chkconfig: - 98 02
#
# description: Sample Application Upstart, using Forever
APPHOME=/opt/sample-app
APPSCRIPT=app.js
@fideloper
fideloper / site.backup.sh
Created May 15, 2012 20:14
Backup whm account files and database
#!/bin/bash
#Show instructions
function show_usage {
echo "Backup account and database, assuming /home/USER filesystem setup."
echo "Usage:"
echo " -h Help menu - See this information"
echo " Files: "
echo " -a Account user name, for use in /home/USER backup. If no path is set via -p flag, the /home/USER path will be backed up. "
echo " -f Filepath to Backup "
@fideloper
fideloper / vim_tmux_setup.sh
Last active August 24, 2022 23:31
Setup Vim+Vundle+Solarized+Tmux in a Vagrant Ubuntu box. This goes with my article on Vim+Tmux here: http://fideloper.com/mac-vim-tmux
#!/usr/bin/env bash
# Bash script to automate Vim+Tmux install as written about here:
# http://fideloper.com/mac-vim-tmux
# Test if Git is installed.
# Installing Git is not the job of this script
git --version 2>&1 >/dev/null
GIT_IS_INSTALLED=$?
@fideloper
fideloper / sphinx.conf
Created October 3, 2012 01:15
Install Sphinx and php .so in Ubuntu 12.04
#############################################################################
## data source definitions
#############################################################################
source users
{
# data source type. mandatory, no default value
# known types are mysql, pgsql, mssql, xmlpipe, xmlpipe2, odbc
type = mysql
@fideloper
fideloper / tags.py
Created November 4, 2016 13:21
Change many aws instances tags (boto3)
import boto3
import sys
ec2 = boto3.client('ec2')
# Grab where backup retention is 14 days so we can reduce it to 7
instances = ec2.describe_instances(Filters=[{'Name': 'tag:Retention', 'Values': ['14']}])
ids = []
@fideloper
fideloper / usevm.md
Created June 6, 2012 02:24
You should develop in a Virtual Machine

#You should do all your LAMP development in a Virtual Machine

##Here's Why:

Many of us develop on Macintoshes. There are many reasons for this, but one of them is that it's based on a Unix platform of some sort. This allows us to run common server software such as Apache, Ruby, Python and Nodejs on our Macs.

Our computers become powerful develoment machines similar to the servers our apps will eventually live on.

Sometime we start our computer only to find Apache won't start, or MySQL can't create a PID file, or we've updated to Mountain Lion and Apache needs to be reconfigured. Death!

@fideloper
fideloper / connections.sh
Created December 19, 2018 19:48
Quick and dirty monitoring of mysql connections
#!/usr/bin/env bash
# 5 minutes between alerts
SECONDS_BETWEEN_ALERTS=300
# Track when we sent the last alert
LAST_ALERT=0
while true; do
NUMBER_CONNECTIONS=$(mysql --defaults-extra-file=/data/.prod.cnf -sNe "select count(*) as connection_count from INFORMATION_SCHEMA.PROCESSLIST;")

Each query in MySQL is running as its own transaction, assuming you didn't change this default configuration, and unless you're starting a transaction manually and running multiple deletes in that one transaction.

Because every query is a transaction, MySQL has to save the data being deleted in case of a rollback. Large deletes means saving a TON of data for that potential case.

Additionally, deletes cause a LOT of writes to the binary log. When the delete completes, the query/results of the delete are committed to the binary log,

@fideloper
fideloper / post_image.php
Created August 2, 2012 19:18
Facebook Code Snippets
<?php
/*
Note that this does not use app icons or links in Timeline post. Some messaging is therefor lost.
*/
require 'fb/src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'SOME_APP_ID',