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 / detect_node.rb
Created January 12, 2015 13:25
Platform independent method to detect a working nodejs binary in the system via a ruby script. (C) MIT
class DetectNode
MIN_VER = [0, 10, 0]
def self.detect
node_bins.each do |node|
detected_version = (`#{node} --version`)[1..-1].split(".") rescue [0,0,0]
if detected_version[0].to_i >= MIN_VER[0] and
detected_version[1].to_i >= MIN_VER[1] and
detected_version[2].to_i >= MIN_VER[2]
return node
@rajiteh
rajiteh / topjobs.js
Created January 14, 2015 15:54
Fix topjobs.lk to open posts in new tabs -- or however you want
$('tr > td:nth-child(3) > h2 > a').each(function() { $(this).attr({ href: $(this).attr('href').match(/\('(.*)',.*/, "")[1], target: '_blank' }); });
#!/usr/bin/env ruby
require 'net/telnet'
localhost = Net::Telnet::new("Host" => "localhost", "Port" => 30002)
for count in 0..9999
pin = sprintf("%4d", count)
puts "Trying #{pin}"
localhost.cmd("String" => "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ #{pin}", "Match" => /^Wrong!.*/n) { |a| puts a }
end
localhost.close
@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,
@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 / 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 / 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 / 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 / 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 / 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: