Skip to content

Instantly share code, notes, and snippets.

View usmanity's full-sized avatar

Muhammad Usman usmanity

View GitHub Profile
@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 / time_remaining.sh
Created February 27, 2013 23:49
battery time remaining macbook
ioreg -w0 -l | grep -i "remaining"
@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 / battery_cycles.sh
Last active December 11, 2015 21:18
check battery cycles on macbook
ioreg -w0 -l | grep "Cycle" | tail -b 1
@usmanity
usmanity / Aaron Swartz: Guerilla Open Access Manifesto
Created January 13, 2013 07:34
Aaron Swartz: Guerilla Open Access Manifesto (making a copy for public access and personal record)
Information is power. But like all power, there are those who want to keep it for themselves. The world’s entire scientific and cultural heritage, published over centuries in books and journals, is increasingly being digitized and locked up by a handful of private corporations. Want to read the papers featuring the most famous results of the sciences? You’ll need to send enormous amounts to publishers like Reed Elsevier.
There are those struggling to change this. The Open Access Movement has fought valiantly to ensure that scientists do not sign their copyrights away but instead ensure their work is published on the Internet, under terms that allow anyone to access it. But even under the best scenarios, their work will only apply to things published in the future. Everything up until now will have been lost.
That is too high a price to pay. Forcing academics to pay money to read the work of their colleagues? Scanning entire libraries but only allowing the folks at Google to read them? Providing scientific a
@usmanity
usmanity / color.js
Created November 1, 2012 04:59
random color in JS
var randomColor = function() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.round(Math.random() * 15)];
}
return color;
};
show = "show indent"
@usmanity
usmanity / debug sess
Created August 7, 2012 05:52
debug sess
<%= debug(params) if Rails.env.development? %>
@usmanity
usmanity / gist:2355218
Created April 10, 2012 22:44
development
O
<[ ]>
_/ \_ OTL OTL OTL OTL
@usmanity
usmanity / index.html
Created February 24, 2012 00:31
CSS and html to make footer stick to the bottom of the screen
<body>
<div id="container">
Container content.
</div>
<footer>
Footer content.
</footer>
</body>