Skip to content

Instantly share code, notes, and snippets.

View jlengstorf's full-sized avatar
💭
partyin

Jason Lengstorf jlengstorf

💭
partyin
View GitHub Profile
@jlengstorf
jlengstorf / git_rm_ls-files.sh
Last active December 12, 2015 08:28
Git command to remove all deleted files
# Removes all deleted files
git rm $(git ls-files -d)
# Removes deleted files in a given directory
git rm $(git ls-files -d path/to/subdir/.)
@jlengstorf
jlengstorf / gist:4121599
Last active October 13, 2015 01:58
One-liner to dump a database and update the URL from the command line
mysqldump -udb_user -p db_name | sed -e 's/olddomain.com/newdomain.com/g' > db_dump.sql
@jlengstorf
jlengstorf / gist:3889744
Created October 14, 2012 20:36
Search for all occurrences of a string, case-insenstive, within the current dir and its subdirs. Returns the file name & line number, plus the matched line
grep -rni "STRING" .
@jlengstorf
jlengstorf / gist:2898957
Last active October 5, 2015 23:57
Find all files over 10MB in size.
find / -mount -noleaf -type f -size +10000k -print0 | xargs -0 ls -lhSr | awk '{printf "%*s %s\n",7,$5":",$9}'
@jlengstorf
jlengstorf / gist:2864077
Created June 3, 2012 16:25
.htaccess commands to increase max upload file size.
php_value upload_max_filesize 20M
php_value post_max_size 20M
@jlengstorf
jlengstorf / backup.sh
Created May 31, 2012 19:37
Script to automate backup of a site's files and DB. (From Lifehacker: http://s.cptr.me/H1z6)
#!/bin/sh
THESITE="example.org"
THEDB="my_database_name"
THEDBUSER="my_database_user"
THEDBPW="my_database_password"
THEDATE=`date +%d%m%y%H%M`
mysqldump -u $THEDBUSER -p${THEDBPW} $THEDB | gzip > /var/www/vhosts/$THESITE/backups/files/dbbackup_${THEDB}_${THEDATE}.bak.gz
@jlengstorf
jlengstorf / gist:2760370
Created May 21, 2012 02:48
#15 Code example from "JSON: What It Is, How It Works, & How to Use It"
loadFlickr("29080075@N02");
@jlengstorf
jlengstorf / gist:2760365
Created May 21, 2012 02:45
#14 Code example from "JSON: What It Is, How It Works, & How to Use It"
function loadFlickr(flickrid)
{
// Display a loading icon in our display element
$('#feed').html('<span><img src="/blog/images/lightbox-ico-loading.gif" alt=""></span>');
// Request the JSON and process it
$.ajax({
type:'GET',
url:"http://api.flickr.com/services/feeds/photos_public.gne",
data:"id="+flickrid+"&lang=en-us&format=json&jsoncallback=?",
@jlengstorf
jlengstorf / gist:2760364
Created May 21, 2012 02:44
#13 Code example from "JSON: What It Is, How It Works, & How to Use It"
function loadFlickr(flickrid)
{
// Display a loading icon in our display element
$('#feed').html('<span><img src="/blog/images/lightbox-ico-loading.gif" alt=""></span>');
// Request the JSON and process it
$.ajax({
type:'GET',
url:"http://api.flickr.com/services/feeds/photos_public.gne",
data:"id="+flickrid+"&lang=en-us&format=json&jsoncallback=?",
@jlengstorf
jlengstorf / gist:2760362
Created May 21, 2012 02:43
#12 Code example from "JSON: What It Is, How It Works, & How to Use It"
({
"title": "Uploads from ennuidesign",
"link": "http://www.flickr.com/photos/ennuidesign/",
"description": "",
"modified": "2009-03-17T03:53:36Z",
"generator": "http://www.flickr.com/",
"items": [
{
"title": "This Is How You Get People to Talk About You",
"link": "http://www.flickr.com/photos/ennuidesign/3361269251/",