Skip to content

Instantly share code, notes, and snippets.

View JingwenTian's full-sized avatar
🎯
Focusing

JingwenTian JingwenTian

🎯
Focusing
View GitHub Profile
@tinogomes
tinogomes / start_stop_memcached_script.sh
Created June 21, 2010 17:34
Script sample to start/stop for linux with nohup
#!/bin/bash
#
BASE=/tmp
PID=$BASE/app.pid
LOG=$BASE/app.log
ERROR=$BASE/app-error.log
PORT=11211
LISTEN_IP='0.0.0.0'
MEM_SIZE=4
@icyleaf
icyleaf / post-receive.sh
Created September 6, 2010 07:55
git autodeploy script when it matches the string "[deploy]"
#!/bin/sh
#
# git autodeploy script when it matches the string "[deploy]"
#
# @author icyleaf <icyleaf.cn@gmail.com>
# @link http://icyleaf.com
# @version 0.1
#
# Usage:
# 1. put this into the post-receive hook file itself below
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@jamesvl
jamesvl / gist:910325
Created April 8, 2011 17:32
Web server rewrite rules for using klein PHP router

URL-rewriting for klein PHP router

Why rewrite URLs? Check Wikipedia

Apache

Make sure AllowOverride is on for your directory, or put in httpd.conf

# Apache (.htaccess or httpd.conf)

RewriteEngine On

@russelyang
russelyang / child.js
Created May 22, 2011 15:51
node.js child_process sample
//var child = process.createChildProcess('sh',
// ['-c', 'echo hello; sleep 1; echo world;']);
//child.addListener('data', function(chunk) {
// console.log(chunk);
//});
var spawn = require('child_process').spawn,
child = spawn('sh', ['-c', 'echo hello; sleep 1; echo world;']);
child.stdout.on('data', function(chunk) {
@olvado
olvado / getAverageColourAsRGB.js
Created June 27, 2011 10:19
Get the average colour of an image in javascript using getImageData in CANVAS
function getAverageColourAsRGB (img) {
var canvas = document.createElement('canvas'),
context = canvas.getContext && canvas.getContext('2d'),
rgb = {r:102,g:102,b:102}, // Set a base colour as a fallback for non-compliant browsers
pixelInterval = 5, // Rather than inspect every single pixel in the image inspect every 5th pixel
count = 0,
i = -4,
data, length;
// return the base colour for non-compliant browsers
@mbijon
mbijon / xss_clean.php
Last active November 1, 2022 03:23
XSS filtering in PHP (cleans various UTF encodings & nested exploits)
<?php
/*
* XSS filter, recursively handles HTML tags & UTF encoding
* Optionally handles base64 encoding
*
* ***DEPRECATION RECOMMENDED*** Not updated or maintained since 2011
* A MAINTAINED & BETTER ALTERNATIVE => kses
* https://github.com/RichardVasquez/kses/
*
* This was built from numerous sources
@juandopazo
juandopazo / lib.js
Created November 15, 2011 14:21
Function.prototype.extend for simple classes in ES5
Object.getOwnPropertyDescriptors = function getOwnPropertyDescriptors(obj) {
var descriptors = {};
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
descriptors[prop] = Object.getOwnPropertyDescriptor(obj, prop);
}
}
return descriptors;
};
@oodavid
oodavid / README.md
Last active April 6, 2024 18:45 — forked from aronwoost/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@renz45
renz45 / An_example.markdown
Last active December 4, 2016 21:01
Re-style Sublime Text 2 sidebar to a darker theme

This re-styles your sublime text 2 sidebar to be darker, so it doesn't blind you when using a dark theme.

Dark sublime text 2 sidebar

Save the Default.sublime-theme file into packages/user