Skip to content

Instantly share code, notes, and snippets.

View shahata's full-sized avatar

Shahar Talmi shahata

View GitHub Profile
cd linter; \
./pslint_selftest.sh; \
./pslint.py ../public_suffix_list.dat;
-n test_NFKC:
OK
-n test_allowedchars:
OK
-n test_dots:
OK
-n test_duplicate:
const {compile, root, chain, setter, arg0} = require('carmi');
const Benchmark = require('benchmark');
const assert = require('assert');
async function go() {
class Implementation1 {
constructor(data) {
this.data = data;
}
setup() {
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install git
brew install zsh
brew install node
curl -L http://install.ohmyz.sh | sh
echo 'alias npmpublic="npm config set registry https://registry.npmjs.org/"' >> ~/.zshrc
echo 'alias npmprivate="npm config set registry http://npm.dev.wixpress.com"' >> ~/.zshrc
npm install -g fed-exam --registry http://npm.dev.wixpress.com
function aBuilderFor(obj) {
const cap = s => s.charAt(0).toUpperCase() + s.slice(1);
return () => new function () {
Object.keys(obj).forEach(key => {
this[`with${cap(key)}`] = value => {
this[`_${key}`] = value;
return this;
};
this[`_${key}`] = typeof obj[key] === 'function' ? obj[key]() : obj[key];
});
@shahata
shahata / time-machine.sh
Created October 19, 2014 16:08
Restore brew and npm symlinks after restore from Time Capsule
brew list | xargs -I % sh -c 'brew unlink %; brew link %'
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
for i in "$(npm prefix -g)/lib/node_modules/"*; do
npm build -g "$i"
done
@shahata
shahata / debounce.js
Last active August 29, 2015 13:57
debounce directive
angular.module('shahata', [])
.directive('debounce', function($timeout) {
return {
require: 'ngModel',
scope: {
debounce: '='
},
link: function($scope,$element, $attrs, ngModelController) {
var pending, viewValue;
var prevRender = ngModelController.$render.bind(ngModelController);
@shahata
shahata / consoleLog.js
Last active December 31, 2015 00:29
Proper way to console log safely
function consoleLog(type) {
var console = window.console || {},
logFn = console[type] || console.log || function() {},
hasApply = false;
// Note: reading logFn.apply throws an error in IE11 in IE8 document mode.
// The reason behind this is that console.log has type "object" in IE8...
try {
hasApply = !! logFn.apply;
} catch (e) {}
//requirements:
//npm install cldr
//npm install csv
//npm install path
'use strict';
var cldr = require('cldr');
var csv = require('csv');
var path = require('path');
@shahata
shahata / jasmine-async-spy.js
Last active December 20, 2015 01:08
A simple jasmine extension to create spies that are able to invoke callbacks when flushed
'use strict';
// createAsyncSpy helps you mock functions that invoke callbacks.
// createAsyncSpy gets two function parameters: mock() and work()
//
// mock() is invoked when the user calls spy()
// work() is called when the user calls spy.flush()
// Both mock() and work() are called with the context and arguments the user passed in his original
// invocation.
//