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

Symfony Security Checker in Laravel

Artisan command for Sensiolabs Security Checker

Require this project in your composer.json file

"sensiolabs/security-checker": "2.x"

Add the following line to app/start/artisan.php:

var str = "[ 70W [ 50H [ 50W + 50W ] + 25H + 25H ] + 30W ]";
str = str.replace(/([\d]+)(W|H)/g, function(match, t1, t2) {
var attr = (t2 === 'H') ? 'height' : 'width';
return '<div ' + attr + "='" + t1 + "%'>";
}).replace(/(]|\+)/g, '</div>').replace(/(\[)/g, '');
console.log(str);
@torifat
torifat / Person.java
Created October 31, 2014 23:14
Java Person Class
public class Person implements Serializable {
private final String firstName;
private final String lastName;
public Person(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName() {
@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) {
@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 / 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);
},
#!/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
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)_
@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) {
@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