Skip to content

Instantly share code, notes, and snippets.


Gilad Peleg pgilad

Block or report user

Report or block pgilad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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 /
Created May 25, 2014
Client exposes API

An API for website's Exposes


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 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 /
Created Oct 27, 2014
Curl and get only response code
curl -sL -w "%{http_code}" "" -o /dev/null
pgilad /
Created Oct 25, 2015
pip upgrade all packages
import pip
import subprocess
for dist in pip.get_installed_distributions():
call_str = "pip install --upgrade {0}".format(dist.project_name)
print "Upgrading {}".format(dist.project_name), shell=True)
pgilad / pre-commit
Created Jun 30, 2015
Precommit git hook
View pre-commit
JS_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E "(.js|.es6)$")
if [ "$JS_FILES" = "" ]; then
exit 0
for file in $JS_FILES; do
pgilad /
Created Feb 10, 2016
Run apachetop on multiple files from find
# Run apachetop on multiple files as a result of find
sudo apachetop $(find /var/log/blazemeter/ -name "*access.log" -print | sed 's/^/-f '/)
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
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')) {
$files = glob(__DIR__ . '/env-config/*.{json,yml}', GLOB_BRACE);
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 = '';
var s = document.getElementsByTagName('script')[0];
View vim search and replace.vim
:args `ag -l word`
:argdo %s/word/newWord/gc | w
pgilad / worker.conf
Created Oct 10, 2016
Blazemeter worker and scheduled worker `.conf` for supervisord
View worker.conf
command=php /home/gilad/vol/www/
You can’t perform that action at this time.