Skip to content

Instantly share code, notes, and snippets.

@HomenSimpsor
HomenSimpsor / ensurePerm.sh
Last active December 13, 2015 22:49
Ensure permissions commands
# make all files 666, all directories 777
# (remove execute, re-set directory-only execute)
# [may not work]
chmod -R -v a-x+rwX .
# all files 666, all directories 755
find $item -type f -print0 | xargs --no-run-if-empty -0 chmod 644
find $item -type d -print0 | xargs --no-run-if-empty -0 chmod 755
# chmod and chown
@HomenSimpsor
HomenSimpsor / .gitignore
Created February 26, 2013 20:39
Ignore vim swaps
.s??
.*.s??
@HomenSimpsor
HomenSimpsor / replaceInFiles.txt
Last active December 14, 2015 06:19
Replace something in every HTML file (alternative to sed)
### Perform a search and replace from the commandline
$ vim -c '%s`search`replace`g' -c 'wq' *.html
### Alternatively, load all your files into vim and use bufdo. Allows you to tweak your search pattern before running the replacement:
$ vim *.html
/search
:bufdo %s``replace`g
@HomenSimpsor
HomenSimpsor / runPython.sh
Last active December 14, 2015 07:19
Running an opt install Python 2.7 on CentOS 5.5
LD_LIBRARY_PATH=/opt/python2.7/lib /opt/python2.7/bin/python
alias p27="LD_LIBRARY_PATH=/opt/python2.7/lib /opt/python2.7/bin/python"
@HomenSimpsor
HomenSimpsor / colortest.pl
Created February 27, 2013 17:47
Test 256 colors via perl
#!/usr/bin/perl
# by entheon, do whatever the hell you want with this file
print "\n";
print "**************************\n";
print "*XTERM 256Color Test Chart\n";
print "**************************\n";
print "* 16 = black\n";
print "* 255 = white\n";
@HomenSimpsor
HomenSimpsor / editNthFile.sh
Last active December 14, 2015 07:19
Edit the nth file currently modified and not staged for commit
vim $(git diff --name-only | sed -n '2 p')
git checkout -f $(git diff --name-only | sed -n '2 p')
@HomenSimpsor
HomenSimpsor / edit-in-2-dirs.sh
Last active December 14, 2015 07:19
Edit any files in two directories that match
vim $(find interface library | xargs grep -RIsl 'Date Display Format' | sort | uniq)
@HomenSimpsor
HomenSimpsor / superPrinter.php
Last active December 14, 2015 07:19
Used for error_logging a bunch of variables all at once.
<?php
$label = 'test';
$data = array (
'label' => $datum
);
$logs[] = array($label, $data);
foreach ($logs as $log):
list($label, $data) = $log;
foreach ($data as $key => $value):
if (is_array($value)):
@HomenSimpsor
HomenSimpsor / getIncrement.sql
Created March 5, 2013 20:41
Get table autoincrement value
SELECT TABLE_ROWS
FROM information_schema.tables
WHERE table_name='table'
AND table_schema = DATABASE();
@HomenSimpsor
HomenSimpsor / singleInserts.sh
Created March 6, 2013 16:24
Dump data only, one insert per line
mysqldump --no-create-info --extended-insert=FALSE etc.