Skip to content

Instantly share code, notes, and snippets.

View usmanity's full-sized avatar

Muhammad Usman usmanity

View GitHub Profile
@usmanity
usmanity / notepad.html
Created January 29, 2013 19:13
a quick one liner html file for taking notes in a browser. CSS added to make it a bit pretty.
<html contenteditable autofocus="true"><style>*{font-family: 'Helvetica Neue', 'Droid Sans', sans-serif; font-size: 19px; font-weight: 200;}</style>
@usmanity
usmanity / time_remaining.sh
Created February 27, 2013 23:49
battery time remaining macbook
ioreg -w0 -l | grep -i "remaining"
@usmanity
usmanity / addEvent.js
Created April 22, 2013 20:24
add event, x-browser
var addEvent = function (obj, eventName, meth){
if (obj.addEventListener) {
obj.addEventListener(eventName, meth, true);
}
else if (obj.attachEvent) {
obj.attachEvent("on" + eventName, meth);
}
else {
obj["on" + eventName] = meth;
}
@usmanity
usmanity / now.js
Created May 1, 2013 23:26
subtract a day (needs underscore)
now = Date.now().toString();
day = 86400;
diff = _.initial(now, 3)
diff = diff.join('') - day
alert("here " + diff)
# not by me
class String
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
colorize(31)
end
def blue
colorize(34)
@usmanity
usmanity / gcf.sh
Created August 21, 2013 18:13
return the latest commit sha from current repo
git log | cut -d " " -f 2 | head -n 1
@usmanity
usmanity / kashmir.css
Created September 8, 2014 03:51
kashmir gradient
background: -webkit-linear-gradient(90deg, #614385 10%, #516395 90%); /* Chrome 10+, Saf5.1+ */
background: -moz-linear-gradient(90deg, #614385 10%, #516395 90%); /* FF3.6+ */
background: -ms-linear-gradient(90deg, #614385 10%, #516395 90%); /* IE10 */
background: -o-linear-gradient(90deg, #614385 10%, #516395 90%); /* Opera 11.10+ */
background: linear-gradient(90deg, #614385 10%, #516395 90%); /* W3C */
@usmanity
usmanity / year
Created December 29, 2014 19:19
year in JS
<script type="text/javascript">
document.write(new Date().getFullYear());
</script>
@usmanity
usmanity / prime
Created December 30, 2014 06:08
prime in python
# http://stackoverflow.com/questions/18833759/python-prime-number-checker
import math
def is_prime(n):
if n % 2 == 0 and n > 2:
return False
return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))
@usmanity
usmanity / color.js
Created January 9, 2015 19:07
colors.js back up for later
var getDailyHex = function(){
var d = new Date();
var month = (d.getMonth() + 1).toString();
var day = function(){ if (d.getDate() < 10) { return '0' + d.getDate() } return d.getDate().toString() };
var year = (d.getFullYear() - 2000).toString();
var dailyHex = month + day() + year;
return dailyHex;
}
var getSecondsHex = function(){