Skip to content

Instantly share code, notes, and snippets.

$.fn.ctrlEnter = function (btns, fn) {
var thiz = $(this);
btns = $(btns);
function performAction (e) {
fn.call(thiz, e);
}
thiz.bind("keydown", function (e) {
@sulram
sulram / wordpress-move.sql
Last active August 29, 2015 14:00
wordpress plugins
mysql -u database_user -p -D database_name < file
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com', 'http://www.new-domain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.old-domain.com', 'http://www.new-domain.com');

ImageMagick and FFMPEG commands

Remember that the order of parameters/options is very important.

convert images and save to another dir
convert *.png -set filename:original %t 'export/%[filename:original].jpg'
resize, change dpi and quality

Apple Scripts for Alfred

ImageMagick

tell application "Finder"

set myWin to window 1
#!/bin/sh
for png in `find $1 -name *.png`;
do
echo "crushing $png"
pngcrush -rem cHRM -rem gAMA -rem iCCP -rem sRGB "$png" temp.png
mv -f temp.png $png
done;
@sulram
sulram / win7config.markdown
Last active August 29, 2015 14:04
windows 7 config

Edit Startup programs

open System Configuration:
C:\Windows\System32\msconfig.exe

Common File Dialog Box - Customize Places Bar

open Local Group Policy Editor:
C:\Windows\System32\gpedit.msc

OpenGL / GLUT build sytem

{
	"cmd": [ "g++ \"$file\" -o \"$file_base_name\" -framework GLUT -framework OpenGL -framework Cocoa && ./\"$file_base_name\""],
	"working_dir": "${project_path:${folder}}",
	"selector": ["source.c++"],
	"shell": true
}
#include <Adafruit_NeoPixel.h>
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(200, PIN, NEO_GRB + NEO_KHZ800);
uint16_t pos = 0;
int tail = 20;
void setup() {
@sulram
sulram / py2app.md
Last active August 29, 2015 14:11
Python Tips

create setup file (once)

$ py2applet --make-setup MyApplication.py
Wrote setup.py

create/update app

$ python3 setup.py py2app

#include <Adafruit_NeoPixel.h>
#include <NanoSoftSensor.h>
#define LED_1 2
#define LED_2 3
#define LED_F 8
NanoSoftSensor soft_audio = NanoSoftSensor(3);
Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(100, LED_1, NEO_GRB + NEO_KHZ800);