Skip to content

Instantly share code, notes, and snippets.

View parvez's full-sized avatar
🦊
🚫 Chrome ❤️ Firefox

Parvez parvez

🦊
🚫 Chrome ❤️ Firefox
View GitHub Profile
== Rules ==
On Infrastructure
-----------------
There is one system, not a collection of systems.
The desired state of the system should be a known quantity.
The "known quantity" must be machine parseable.
The actual state of the system must self-correct to the desired state.
The only authoritative source for the actual state of the system is the system.
The entire system must be deployable using source media and text files.
@parvez
parvez / linked_list.rb
Created March 29, 2012 10:49
Linked List in Ruby
class LinkedList
include Enumerable
def initialize
@first = Node.new nil
@last = Node.new nil
@first.next = @last
@last.prev = @first
@parvez
parvez / .bash_profile
Created March 29, 2012 10:29
My Bash Profile - Encryptions
aes_encrypt() {
echo -n "Password: ";stty -echo;read password;stty echo;echo "";
openssl enc -e -aes256 -base64 -pass "pass:$password" -in $1 -out $2
}
aes_decrypt() {
echo -n "Password: ";stty -echo;read password;stty echo;echo "";
openssl enc -d -aes256 -base64 -pass "pass:$password" -in $1 -out $2
}
alias md5='md5 -r'
alias md5sum='md5 -r'
@parvez
parvez / wifi_info_to_location.sh
Created March 29, 2012 11:15
wifi info to location
`airport -s -x | egrep 'BSSID|>CHANNEL<|NOISE|SSID_STR|RSSI' --after-context=1 \
| egrep -v "AGE|array|WPA|80211" | tr '\n' ' ' | tr -d '\t' \
| sed -e 's/<[^>]*>//g' \
-e 's/ -- /, /g' \
-e 'y/:/-/' \
-e 's/ \([0-9]\)-/ 0\1-/g' -e 's/-\([0-9]\)\([-|,]\)/-0\1\2/g' \
-e 's/BSSID \([a-f0-9-]*\)/{"mac_address": "\1"/g' \
-e 's/CHANNEL \([0-9]*\)/"channel": \1/g' \
-e 's/NOISE \([0-9]*\)/"signal_to_noise": \1/g' \
-e 's/RSSI \([0-9]*\)/"signal_strength": \1/g' \
@parvez
parvez / htaccess
Created March 29, 2012 11:24
Force HTTPS with Rewrite Rule
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://www.mydomain.com%{REQUEST_URI} [L,R]
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^.*$ https://www.mydomain.com%{REQUEST_URI} [L,R]
@parvez
parvez / .bash_profile
Created March 29, 2012 10:33
My Bash Profile - Quick
search() {
find . –name "*.*" -exec grep -l $1 {} \;
}
alias ll='ls -lha $1'
alias ..='cd ..'
alias ...='cd ../..'
convert2pdf() {
/System/Library/Printers/Libraries/convert -f "$1" -o "$2" -j "application/pdf"
}
@parvez
parvez / watch_dir.sh
Created March 29, 2012 11:30
Watch a Directory
#!/bin/sh
while (true)
do
ls -la some/directory
sleep 1
clear
done
@parvez
parvez / gist:5095854
Created March 6, 2013 00:57
Awesome Cursor Movement
<!doctype html><meta charset='utf-8'>
<link rel='stylesheet' href='http://espadrine.github.com/aulx/demo/codemirror/lib/codemirror.css'>
<style>
div.CodeMirror-cursor {
transition-property: top, left;
transition-duration: 0.1s;
-webkit-transition-property: top, left;
-webkit-transition-duration: 0.1s;
-moz-transition-property: top, left;
-moz-transition-duration: 0.1s;
@parvez
parvez / gist:5106409
Created March 7, 2013 08:19
Disable font enumeration for Adobe Flash
Disable font enumeration for Adobe Flash through mms.cfg:
DisableDeviceFontEnumeration=1
File Location:
32-bit Windows - %WINDIR%\System32\Macromed\Flash
64-bit Windows - %WINDIR%\SysWow64\Macromed\Flash
Macintosh - /Library/Application Support/Macromedia
Linux - /etc/adobe/
@parvez
parvez / check_for_new_version.html
Created March 21, 2013 04:58
JavaScript + CSS based Update Check
<script>
var head = document.getElementsByTagName("head")[0];
var css = document.createElement('link');
css.type = 'text/css';
css.rel = 'stylesheet';
css.href = 'http://product.website.here/update_1.0.css?'+Date.now();
// css.href = 'http://product.website.here/update_1.2.css?'+Date.now(); Uncomment for version 1.2
css.media = 'screen';
head.appendChild(css)
</script>