Skip to content

Instantly share code, notes, and snippets.

View or9's full-sized avatar

Rahman Malik or9

  • Detroit
View GitHub Profile
#!/bin/bash
servers=(
# Servers to start
# Store location in separate script file so gnome-terminal doesn't get confused
"/home/drahman/StartServerTomcat8"
"/home/drahman/StartServerGeronimo"
#"/usr/share/tomcat/bin/catalina.sh\ run"
#"/usr/share/geronimo/bin/geronimo\ run"
)
@or9
or9 / aria.bat
Created March 19, 2015 17:30
Script for Aria2c to download with default options from torrent (file or magnet URL) or file (ending in .txt)
@echo off
@rem interpret extension of first argument
set extension=%~x1
echo extension is %extension%
goto CHECKARGS
rem ###################
@or9
or9 / canary.sh
Created March 19, 2015 22:20
Google Chrome (Canary / Chromium) startup scripts with flags
#!/bin/bash
/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --disable-web-security --enable-local-file-accesses
@or9
or9 / pathogenUpdater.sh
Last active August 29, 2015 14:17
Update script for looping through Git repos in a directory and updating each. Useful for Pathogen if using VIM
#!/bin/sh
# Example filesystem:
# ~/.vimrc/bundle/YouCompleteMe
# …nerdtree
# …molokai
# …clang_complete
# …vim-airline
#
# Usage (assuming this file's name is update.sh)
@or9
or9 / terminalColors.html
Created March 19, 2015 22:24
HTML file of color codes for terminal
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!--<link rel="shortcut icon" type="image/x-icon" href="….ico">-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="How to set terminal colors on Mac OS X">
<meta name="keywords" content="terminal colors, OS X, Mac, CLI">
<meta name="author" content=":Durmon">
<meta http-equiv="Content-Language" content="en">
@or9
or9 / supercon.md
Created March 19, 2015 22:27
Something about Javascript; constructors and functions

#Constructors Just Because Just another document on constructors because I think they're pretty cool, and somebody asked about prototype yesterday.

##Function / variable hoisting We'll take a short look at this behavior of instantiating a constructor in a way which appears to be prior to declaration. But first, just a bit of info on types of functions in JavaScript, namely, named functions and anonymous functions:

  • function someFn() {} // Named function, will be hoisted within scope
  • var someFn = function() {} // Anonymous function with pointer. Will not be hoisted. Available only after declaration
  • var someFn = function someFn() {} // Named function with pointer. Will not be hoisted (var nor function). It may help in stack tracing, but not sure why you would use this
  • someFn = function() {} // Anonymous function with pointer. Will be hoisted because of violation of scope, will always be global, and will throw exception in strict mode. Don't do this
@or9
or9 / app_defineProperties.js
Last active August 29, 2015 14:18
Revealing module app thing
var app = (function init(doc, undefined) {
// do stuff
return Object.defineProperties({}, {
"hi": { value: hi },
"bye": { value: bye }
});
function hi() {
// hi
@or9
or9 / SSH_SOCKS_Proxy.sh
Created April 18, 2015 13:50
Standard SSH tunnel to my server; can be used as a SOCKS proxy
ssh -vnN -D 1080 $1@xf0x.duckdns.org
@or9
or9 / Array.prototype.extractDiff.js
Last active January 18, 2016 05:13
Extract an array of differences by key from two arrays of objects
Array.prototype.extractDiff = extractDiff;
var arr1 = [{ hash: 1234 }, { hash: "abcdefghijk" }];
var arr2 = [{ hash: 1234 }, { hash: "abcdefghijklmnopqrstuvwxyz" }];
var arr3 = [{ hash: 1234 }, { hash: "abcdefghijklmnopqrstuvwxy" }, { hash: "xyz1234" }];
var arr4 = [{ hash: "abcdefghijklmnopqrstuvwxy" }, { hash: "xyz1234" }, { hash: 1234 }];
var diff1 = arr1.extractDiff(arr2, "hash");
var diff2 = arr3.extractDiff(arr1, "hash");
var diff3 = arr4.extractDiff(arr3, "hash"); // returns [] because 3 and 4 are just different arrangements of same objects
@or9
or9 / hexdumpSearch.sh
Last active July 30, 2016 18:40
Search for a value in a file
#!/bin/bash
FILE_TO_SEARCH_IN=$1
STRING_TO_SEARCH_FOR=$2
VALUE_TO_INSERT=$3
#TODO: figure out how to get only the address PLUS OFFSET
ADDRESS_TO_INSERT=`hexdump -C $FILE_TO_SEARCH_IN | grep $STRING_TO_SEARCH_FOR`
function printAddress {
echo $ADDRESS_TO_INSERT