Skip to content

Instantly share code, notes, and snippets.

View pcdinh's full-sized avatar

Pham Cong Dinh pcdinh

View GitHub Profile
ssh -f remote_user@remote_server -L 6378:remote_server:6379 -N
# -f -- backgrounds ssh right before execution of the command
# -L -- Forwards localhost:6378 to remote_server:6379 (encrypted and authenticated)
# -N -- Don't execute a remote command, just forward the port
# Start a redis server on remote_server on port 6379:
redis-server
# on the local machine telnet localhost 6378
function _ajax_request(url, data, callback, type, method) {
if (jQuery.isFunction(data)) {
callback = data;
data = {};
}
return jQuery.ajax({
type: method,
url: url,
data: data,
success: callback,
// Creating a plugin with $.myNS.public_method1() and $.myNS.public_method2() methods, a few different ways.
(function($){
var private_var,
myNS = $.myNS = {},
public_method2;
myNS.public_method1 = function(){
private_method();
# Config for Nginx to act as a front-end for Riak
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc)
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_)
# Config is in /etc/nginx/sites-available/default or somewhere like that
# Set up load-balancing to send requests to all nodes in the Riak cluster
# Replace these IPs/ports with the locations of your Riak nodes
upstream riak_hosts {
server 127.0.0.1:8098;
#pre requisites
aptitude install -y build-essential libtool libltdl3-dev libgd2-xpm-dev libmcrypt-dev libxml2-dev libmysqlclient15-dev flex m4 awk automake autoconf bison make libbz2-dev libpcre3-dev libssl-dev zlib1g-dev vim re2c
aptitude install -y mysql-client mysql-client mysql-common mysql-server mysql-server mysql-server-core
aptitude install -y libtidy-dev curl libcurl4-openssl-dev libcurl3 libcurl3-gnutls zlib1g zlib1g-dev libxslt1-dev libzip-dev libzip1 libxml2 libsnmp-base libsnmp15 libxml2-dev libsnmp-dev libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev zlib1g zlib1g-dev libfreetype6 libfreetype6-dev libbz2-dev libxpm4-dev libmcrypt-dev libmcrypt4
aptitude install -y libxml2-dev libevent-dev
#modify php-fpm config at /usr/local/etc/php-pfm.conf
#copy php-fpm init script under sapi/fpm/php-fpm to /etc/init.d/
#get php from svn
<?php
/**
* Handles SENDs to STOMP
* Only tested with the rabbitmq stomp gateway and rabbitmq server 1.4.0
* Only supports sending message to stomp, no support for other commands
*
* Original source: http://code.google.com/p/simplisticstompclient/
*
* Changes: Added ability to specify host
#!/bin/bash
echo "Flushing iptables..."
iptables -F
echo "SSH Allowed"
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
echo "allow from localhost"
iptables -A INPUT -i lo -j ACCEPT

Deploying an app for the first time

Remotely:

sudo mkdir /var/www/dashboard.app
sudo chown -R deploy:deploy /var/www/dashboard.app/

Locally:

cap deploy:setup

#! /bin/sh
# drupalir.sh, v 0.9.1
#
# Supplied by Quiptime Group
# Developed 2010 by Siegfried Neumann <quiptime@gmail.com>
#
# This file is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation.
"""
This is a simple Redis-based queue. Two features that I needed were
uniqueness (i.e. if an item exists in the queue already, it won't be
added again) and a delay like beanstalkd where an item must wait a
specified time before it can be popped from the queue. There are a
number of other Redis-based queues that have many more features but
I didn't see one that had these two features together. This 50-line
class works for my needs. It may or may not work for you. Feel free
to copy this and build on it.