Skip to content

Instantly share code, notes, and snippets.

View torifat's full-sized avatar
🇸🇩
Why do we even have this here?

Rifat Nabi torifat

🇸🇩
Why do we even have this here?
View GitHub Profile
@torifat
torifat / dabblet.css
Created December 31, 2011 01:12
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height:100%;
@torifat
torifat / extract
Created June 10, 2012 10:58
extract
#!/usr/bin/env bash
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.jar) jar xvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
@torifat
torifat / php-switch
Created July 30, 2012 18:11
a php switching utillity for homebrew
#!/bin/bash
# php switch for homebrew
# $ brew tap josegonzalez/php && brew install php53 --with-mysql && brew install php54 --with-mysql
# Might as well ask for password up-front, right?
sudo -v
VERSION_FILE="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/php-switch.version"
@torifat
torifat / fix-sublime-text-2-icon
Created August 2, 2012 10:46
Restore previously used custom icon of Sublime Text 2
#!/bin/bash
cp -f ~/.Trash/Sublime\ Text\ 2.app/Contents/Resources/Sublime\ Text\ 2.icns /Applications/Sublime\ Text\ 2.app/Contents/Resources/Sublime\ Text\ 2.icns
@torifat
torifat / rivets.config.js
Created November 29, 2012 19:55
RivetsJS Adapter for BackboneJS with RequireJS
define(['rivets', 'backbone'], function(rivets, Backbone){
rivets.configure({
adapter: {
subscribe: function(obj, keypath, callback) {
if (obj instanceof Backbone.Collection) {
obj.on('add remove reset', function () {
callback(obj[keypath]);
});
} else {
obj.on('change:' + keypath, function (m, v) {
def findAdjWithBase(w: Int, h: Int)(r: Int, c: Int) = {
def check(x: (Int, Int)) = 0 < x._1 && x._1 <= h && 0 < x._2 && x._2 <= w
if(check((r, c))){
List((-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1))
.map(x => (x._1 + r, x._2 + c)).filter(check)
}
}
val findAdj = findAdjWithBase(9, 9)_
#!/bin/bash
for man in 1 3 5 7; do
ln -sf /usr/local/lib/node_modules/npm/man/man${man}/* /usr/local/share/man/man${man}
done
ln -sf /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
npm update npm -g
@torifat
torifat / config.js
Created January 12, 2014 23:05
What's the correct way to communicate between controllers in AngularJS? - http://cl.ly/TJVG
angular
.module('MyApp')
.config(['$provide', function($provide){
$provide.decorator('$rootScope', ['$delegate', function($delegate){
Object.defineProperty($delegate.constructor.prototype, '$onRootScope', {
value: function(name, listener){
var unsubscribe = $delegate.$on(name, listener);
this.$on('$destroy', unsubscribe);
},
@torifat
torifat / fnMix.js
Last active August 29, 2015 13:56
Functional Mixin
var withWalking = function() {
this.walk = function() {
console.log(this.name + ' is walking');
};
this.turn = function(direction) { console.log('turning', direction);
};
this.stopWalking = function() {
console.log('stopped walking');
};
};
@torifat
torifat / list.js
Last active August 29, 2015 14:05
List.js
// TODO: Add Validations
var List = function (value) {
this.value = value || [];
};
List.prototype.unit = function (value) {
return new List(value);
};
List.prototype.flatMap = function (fn, context) {