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 / permissions.sh
Created February 6, 2014 19:44
find and update permissions
find * ! -user admin ! -user root -user nobody -type d -maxdepth 1 -exec chown -R DOMAIN\\{}:DOMAIN\\domain\ users {} \; -exec chmod -R 640 {} \; -exec echo "[" `date -Iseconds` "]: PERMISSIONS UPDATED FOR " {} \;
@rajiteh
rajiteh / sfpawards.js
Created September 9, 2014 09:16
Hover over the Award link text instead of opening a popup window to quickly read award descriptions in YorkU's SFP application.
//Execute the following javascript at the Award selection page of SFP and wait for the message 'success! :)'
var script = document.createElement("script");
script.src = "https://code.jquery.com/jquery-2.1.1.min.js";
script.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(script);
var interval = setInterval(function() {
if (typeof jQuery === "function") {
clearInterval(interval);
jQuery(function($) {
var $dom = $('a[target="awardDescription"]')
#!/bin/bash
#mongod on terminal with logging to stdout (so dirty it smells)
#alias to 'mongod' for extra points
tail -f /usr/local/var/log/mongodb/mongo.log &;mongod --config /usr/local/etc/mongod.conf;kill $(ps | grep 'tail -f /usr/local/var/log/mongodb/mongo.log' | head -1 | awk '{ print $1 }')
#!/bin/sh
#Get sudo
sudo echo
switch_version()
{
select version
do
echo
#!/bin/sh
# http://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommited-changes
require_clean_work_tree () {
# Update the index
git update-index -q --ignore-submodules --refresh
err=0
# Disallow unstaged changes in the working tree
if ! git diff-files --quiet --ignore-submodules --; then
#!/bin/bash
# usage: script.name <url_to_ping>
url=$1
while true
do
curl -iI $url
sleep 60
done
@rajiteh
rajiteh / PGSQL_INSERT_IGNORE.SQL
Created December 12, 2014 04:50
Postgres way of doing mysql insert ignore
INSERT INTO ew_events (
id,
name,
CONTENT,
url,
img,
LOCATION,
lat,
lng,
date_start,
@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