Skip to content

Instantly share code, notes, and snippets.

Avatar
🔭

Gilad Peleg pgilad

🔭
View GitHub Profile
@aslansky
aslansky / gist:8741515
Created Jan 31, 2014
gulp livereload (gulp 3.5.0)
View gist:8741515
var gulp = require('gulp');
var gutil = require('gulp-util');
var sass = require('gulp-sass');
var lr = require('tiny-lr');
var http = require('http');
var path = require('path');
var ecstatic = require('ecstatic');
var tlr = lr();
var livereload = function (evt, filepath) {
tlr.changed({
@pgilad
pgilad / hasEvery.lodash.js
Last active Aug 29, 2015
Check if a collection has truthy values for keys
View hasEvery.lodash.js
//to validate if a collection has all the desired keys and they are truthy:
var hasEvery = function(desiredKeys, collection) {
return _.all(desiredKeys, _.result.bind(collection, collection));
};
var desiredKeys = ['hello', 'there', 'isIt'];
var collection = { hello: 1, there: 1, isIt: true};
hasEvery(desiredKeys, collection);
//-> true
@pgilad
pgilad / exposes.md
Created May 25, 2014
Client exposes API
View exposes.md

An API for website's Exposes

Purpose

Imagine you had a Chrome/Firefox/IE? extension that can use the same keys to handle the same basic actions throughout every web page you visit.

Lets assume your are visiting google.com and search for Js Slider. Now you want to move to the next page of results. Currently you have to click Next Page.

But what if Google implements their very own keyboard keys for their search. So they decide that if your press Ctrl+Alt+N you move to the next page. But what if Bing makes it Ctrl+Alt+P? And Yahoo makes it Cmd+Alt+N?

@pgilad
pgilad / res.sh
Created Oct 27, 2014
Curl and get only response code
View res.sh
curl -sL -w "%{http_code}" "http://somesite.com" -o /dev/null
@pgilad
pgilad / pip-upgrade.py
Created Oct 25, 2015
pip upgrade all packages
View pip-upgrade.py
import pip
import subprocess
for dist in pip.get_installed_distributions():
call_str = "pip install --upgrade {0}".format(dist.project_name)
print
print "Upgrading {}".format(dist.project_name)
subprocess.call(call_str, shell=True)
View statsdtest.py
#!/usr/bin/python
import random
import time
import statsd
ctr_name = 'stats.test.1'
while True:
client = statsd.StatsClient('localhost', 8125)
rand = random.randrange(1, 250)
print('count: (%d)' % rand)
@pgilad
pgilad / env.php
Created Feb 28, 2016
Env.php that loads yml and json files from env-config and returns the accumulated configuartion
View env.php
<?php
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE ^ E_STRICT);
if (function_exists('newrelic_disable_autorum')) {
newrelic_disable_autorum();
}
$files = glob(__DIR__ . '/env-config/*.{json,yml}', GLOB_BRACE);
@weotch
weotch / main.js
Last active Mar 13, 2016
Backbone routing example using require.js
View main.js
// This our standard require js bootstrap file. It assumes you are using the
// require-jquery.js file that require.js provides
// Set the require.js configuration for the application
require.config({
// Base path used to load scripts
baseUrl: 'js/',
// Prevent caching during dev
urlArgs: "bust=" + (new Date()).getTime(),
@pgilad
pgilad / gaInit.js
Last active Jun 22, 2016
Google Analytics ga.js for chrome extensions - snippit that doesn't report on development enviornment
View gaInit.js
//replace UA-XXXXXXXX-X *ONLY* with your real UA Account ID.
//DO not replace the UA-99999999-X with anything, as that is the point of this.
var _gaq = _gaq || [];
(function () {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
@rgrove
rgrove / delete-tags.sh
Created Aug 7, 2011
Shell script to delete useless build tags from GitHub forks of YUI 3
View delete-tags.sh
#!/bin/bash
# This script will delete *all* local and remote tags from any git repo you run
# it in, unless they begin with "v". Please use it to remove the hundreds of
# build tags from your YUI 3 fork.
#
# This script will not delete branches; just tags.
set -e
You can’t perform that action at this time.