Skip to content

Instantly share code, notes, and snippets.

View xeoncross's full-sized avatar

David Pennington xeoncross

View GitHub Profile
# To batch process a whole folder of images you just copy them to a thumbnail folder and use ImageMagick to crop them to the size you want.
cd /home/user/photos/holidays
mkdir thumbs
cp /home/user/photos/holidays/* /home/user/photos/holidays/thumbs/
cd thumbs
# To cut out a section of the image (not resizing it) widthXheight+xoffset+yoffset
mogrify -crop 940x300+0+50 *
@xeoncross
xeoncross / backup.sh
Created October 19, 2010 18:39
Backup all files in this directory and all sub directories by size or type
# backup small files (text files?)
find /home/user -type f -size -100k -print0 | tar -c -z --null --files-from=- -f backup.small.files.tgz
# Backup PHP files
find /home/user -type f -name '*.php' -print0 | tar -c -z --null --files-from=- -f backup.php.files.tgz
@xeoncross
xeoncross / svn.undo.sh
Created October 25, 2010 20:31
revert a svn revision
# Go back to an older revision
svn update -r 499
# or older version of file
svn update -r 499 file
# or just open a copy in a file for viewing
svn cat -r 499 file | less
# Find the current revision
@xeoncross
xeoncross / AS.autoexec.cfg
Created November 21, 2010 01:24
assaultcube scripts
////////////////////////////////////
//screenshot @ end of game
start_intermission = [
sleep 20 [ screenshot ] //sleep because you might get a black screen otherwise
]
// Hide the "GHOST" notice when watching
// /hidespecthud 1
@xeoncross
xeoncross / mysql.proc.sql
Created November 27, 2010 01:56
MySQL sample proc showing insert loop
mysql> delimiter $$
mysql>
CREATE PROCEDURE myFunction()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE (i<=1000000) DO
INSERT into table (fk1_id, fk2_id, date) values (i, 1000000 - i, NOW());
@xeoncross
xeoncross / my.cnf
Created January 4, 2011 04:07
My default MySQL 5+ config for shared VPS using UTF-8
# Currently don't have most of the conf finalized - will update this when I do.
[mysqld]
init_connect='SET collation_connection = utf8_general_ci; SET NAMES utf8;'
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake
@xeoncross
xeoncross / javascript.$.js
Created January 14, 2011 01:39
A jQuery-like global JavaScript selector core
var jQuery = (function() {
// Define a local copy of jQuery
var jQuery = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context );
};
jQuery.fn = jQuery.prototype = {
@xeoncross
xeoncross / gitsetup.sh
Created January 23, 2011 19:02
Setup remote git repo over SSH
# On the server create a empty master codebase repo
$git --init --bare
# On your machine create the repo
$git --init
# ...do git stuff and commit...
# Then add the codebase over SSH
$ git remote add codebase ssh://youruserhere@example.com:22/var/www/git/repo/
@xeoncross
xeoncross / tumblr.theme
Created January 29, 2011 04:38
Important changes to add info to your tumblr blog
# We want pages to be called the name of the post
<title>{block:PostTitle}{PostTitle} - {/block:PostTitle}{Title}</title>
# Or if you also want a title for non-text posts
<title>{block:PostTitle}{PostTitle} - {/block:PostTitle}{block:PostSummary}{PostSummary} - {/block:PostSummary}{Title}</title>
# http://developers.facebook.com/docs/reference/plugins/like
# We want a facebook like button
<iframe src="http://www.facebook.com/plugins/like.php?href={URLEncodedPermalink}&amp;layout=button_count&amp;show_faces=false&amp;width=98&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:80px; height:30px;margin-top:2em;text-align:right;"></iframe>
@xeoncross
xeoncross / page-to-white.js
Created February 1, 2011 18:57
Make any website page into an easy-to-read, black text on white. Removes all backgrounds and colors. Drag to your bookmark bar.
javascript:(function(){var newSS, styles='* { background: white ! important; color: black !important } :link, :link * { color: #0000EE !important } :visited, :visited * { color: #551A8B !important }'; if(document.createStyleSheet) { document.createStyleSheet(%22javascript:'%22+styles+%22'%22); } else { newSS=document.createElement('link'); newSS.rel='stylesheet'; newSS.href='data:text/css,'+escape(styles); document.getElementsByTagName(%22head%22)[0].appendChild(newSS); } })();