Skip to content

Instantly share code, notes, and snippets.

View rajiteh's full-sized avatar
🅱️
'sup

Raj Perera rajiteh

🅱️
'sup
  • @ubisoftinc
  • Toronto, ON
View GitHub Profile
@rajiteh
rajiteh / heroku_pg_sync.sh
Last active August 29, 2015 14:23
Sync two Heroku Postgres databases via pg:backups
#!/bin/bash
set -e
######## Heroku Postgres Sync Script #######
## Author: Raj <rajiteh@gmail.com>
## License: MIT
##
## Syntax: sync.sh FROM_APP TO_APP [USE OLD BACKUP]
##
## FROM_APP Source application to obtain the backup.
## TO_APP Destination application to restore.
toSortArray.sort( -> Math.floor(Math.random() * 3) - 1)
# Generated by iptables-save v1.4.21 on Fri Mar 20 00:10:03 2015
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [113:16204]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j DROP
-A INPUT -p tcp -m tcp ! --tcp-flags FIN,SYN,RST,ACK SYN -m state --state NEW -j DROP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,SYN,RST,PSH,ACK,URG -j DROP
-A INPUT -i lo -j ACCEPT
@rajiteh
rajiteh / keybase.md
Created April 11, 2015 16:38
Keybase Proof

Keybase proof

I hereby claim:

  • I am rajiteh on github.
  • I am rajitha (https://keybase.io/rajitha) on keybase.
  • I have a public key whose fingerprint is 83F1 1C13 5A27 4D9F 5863 96DD 78BE 54F4 A0FF D6F6

To claim this, I am signing this object:

@rajiteh
rajiteh / bootstrap.sh
Last active September 29, 2015 10:46
Installs nvm, rbenv, apache, mysql and php5-fpm, supports selectively installing components. Tested on Ubuntu 14.04 with Vagrant
#!/usr/bin/env bash
set -e
# BootstrapShhhhhh
# ================
#
# Author: @rajiteh <rajiteh@gmail.com>
# License: MIT
#
# Installs a bunch of sh!.
@rajiteh
rajiteh / Vagrantfile
Last active August 29, 2015 14:17
Vagrantfile for quick deployments using bootstrap.sh
# -*- mode: ruby -*-
# vi: set ft=ruby :
#vagrant plugin install vagrant-hostmanager
BOX_NAME="devbox"
ALIAS="#{BOX_NAME}.local"
HOSTNAME="#{BOX_NAME}-dev"
MOUNT_POINT="/vagrant"
Vagrant.configure(2) do |config|
@rajiteh
rajiteh / postgres_peer_enable.sh
Last active August 29, 2015 14:16
Enable local peer connections for postgresql. (version independent)
#!/bin/sh
echo "local postgres postgres peer" >> /etc/postgresql/$(postgres --version | sed 's/.*\(9\.[0-9]\)\.[0-9]/\1/')/main/pg_hba.conf
@rajiteh
rajiteh / fix_libtinfo_dep.md
Created January 25, 2015 23:43
Fixing "undefined reference to symbol 'acs_map'" / "error adding symbols: DSO missing from command line"

If you get a compiler error while trying to compile a source that has dependencies for libtinfo you might encounter an error similar to below on CentOS 6.

cc  -g -O2   -o ncdu src/browser.o src/delete.o src/dirlist.o \
  src/dir_common.o src/dir_export.o src/dir_import.o src/dir_mem.o \
  src/dir_scan.o src/exclude.o src/help.o src/main.o src/path.o \
  src/util.o  -lncursesw  
/cs/local/bin/ld: src/util.o: undefined reference to symbol 'acs_map'
/lib64/libtinfo.so.5: error adding symbols: DSO missing from command \
  line
@rajiteh
rajiteh / inject_jquery.js
Last active August 29, 2015 14:14
Inject jQuery to any website with this one simple trick!
//Paste this on the console.
//Your jQ code should go in function 'jqExec'
//You can override the version by changing the 'version' parameter.
(function(version) {
if (typeof version == "undefined") { version = "2.1.1"; }
var script = document.createElement("script");
script.src = "https://code.jquery.com/jquery-" + version + ".min.js";
script.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(script);
@rajiteh
rajiteh / gpa_calculator.js
Created January 25, 2015 02:34
York University GPA Calculator
// Get JQuery Injector for chrome : https://chrome.google.com/webstore/detail/jquery-injector/indebdooekgjhkncmgbkeopjebofdoid?hl=en
// 1. Login to PPY and go to URL: https://wrem.sis.yorku.ca/Apps/WebObjects/ydml.woa/wa/DirectAction/document?name=CourseListv1
// 2. Inject jQuery and paste this in the console.
// 3. ????
// 4. Get depressed.
var grades = {};
var grade_points = {
"F": 0,
"E": 1,
"D": 2,