Skip to content

Instantly share code, notes, and snippets.

View usmanity's full-sized avatar

Muhammad Usman usmanity

View GitHub Profile
@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(){
@usmanity
usmanity / palindrome.js
Created August 6, 2015 03:53
a simple gist for finding a palindrome in javascript
function isPalindrome(p){
if (p.length == 0 || p.length == 1) {
return true;
} else if (p[0] == p[p.length - 1]) {
return isPalindrome(p.slice(1, p.length - 1));
} else {
return false;
}
}
@usmanity
usmanity / fibonacci.js
Created August 6, 2015 04:01
fibonacci sequence in javascript
function fib(x){
if (x == 0 || x == 1) {
return 1;
} else {
return fib(x-1) + fib(x-2);
}
}
@usmanity
usmanity / rails_404.rb
Created August 4, 2011 07:57
quick way to forward errors from a rails app to 404. suggest something better if this isn't the best way to go about this
def method_missing(id, *args)
redirect_to '/404.html'
end
@usmanity
usmanity / MacVim alias
Created September 19, 2011 23:47
short and you'll be surprised how easy it is to type on the keyboard. opens mvim from CLI and displays: Opening MacVim..
alias 'm.'='mvim .;echo "Opening MacVim..."'
@usmanity
usmanity / gist:1233450
Created September 21, 2011 22:00
Pull first and if no conflicts, do a push
git pull [optional filename] && git push [optional filename]
sass --watch public/sass:public/stylesheets --style compact