Skip to content

Instantly share code, notes, and snippets.

View pgilad's full-sized avatar
🔭

Gilad Peleg pgilad

🔭
View GitHub Profile
@joelhooks
joelhooks / gear.md
Last active April 2, 2024 20:18
Podcasting Gear List
@aslansky
aslansky / gist:8741515
Created January 31, 2014 19:44
gulp livereload (gulp 3.5.0)
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({
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active February 12, 2024 17:18
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@pgilad
pgilad / getSubdomain.js
Last active October 10, 2018 11:55
Regex for matching subdomains in document.location.hostname
var getSubdomain = function (baseDomain) {
if (!baseDomain) {
return null;
}
var regSub = new RegExp('^((?!' + baseDomain + '|www)([^.]*))', 'g');
var _subdomain = document.location.hostname.match(regSub);
if (_subdomain && _subdomain[0]) {
return _subdomain[0];
} else {
@pgilad
pgilad / hasEvery.lodash.js
Last active August 29, 2015 14:00
Check if a collection has truthy values for keys
//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
@pjobson
pjobson / remove_mcafee.md
Last active March 26, 2024 04:26
OSX McAfee Removal

Removal of McAfee from OSX

Note: This was written in 2015, it may be out of date now.

There are a lot of commands here which I use sudo if you don't know what you're doing with sudo, especially where I rm you can severely screw up your system.

There are many reasons which you would want to remove a piece of software such as McAfee, such as not wanting it to hammer your CPU during work hours which seems like primetime for a virus scan.

I intend this to be a living document, I have included suggestions from peoples' replies.

@pgilad
pgilad / gulpfile.js
Last active November 27, 2017 21:44
gulpfile regular flow
var path = require('path');
var gulp = require('gulp');
var streamqueue = require('streamqueue');
var $gulp = require('gulp-load-plugins')({
lazy: false
});
var prependBowerPath = function (package) {
return path.join('./src/bower_components/', package);
};
@pgilad
pgilad / exposes.md
Created May 25, 2014 10:32
Client exposes API

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?

@othiym23
othiym23 / npm-upgrade-bleeding.sh
Created September 20, 2014 19:36
a safe way to upgrade all of your globally-installed npm packages
#!/bin/sh
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
do
npm -g install "$package"
done
@deanishe
deanishe / workflow-install.py
Last active September 21, 2023 15:38
Script to install/symlink Alfred workflows. Useful for workflow developers.
#!/usr/bin/python
# encoding: utf-8
#
# Copyright (c) 2013 <deanishe@deanishe.net>.
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
# Created on 2013-11-01
#