Skip to content

Instantly share code, notes, and snippets.

View bellentuck's full-sized avatar

Ben Ellentuck bellentuck

  • New York, NY
View GitHub Profile
@skoshy
skoshy / isFalsy.js
Last active January 26, 2018 17:07
Determines if any value is "falsy" in JavaScript
// this function takes in any parameter and can tell if it's "falsy" or not.
// falsy means it's either false, 0, null, undefined, NaN, or an empty string/array/object
// see the test cases at the bottom for a clearer picture
function isFalsy(item) {
try {
if (
!item // handles most, like false, 0, null, etc
|| (
typeof item == "object" && (
@jonschlinkert
jonschlinkert / zip.js
Last active February 8, 2024 08:26
versatile JavaScript "zip" function. Works with objects, arrays, and yep - even strings.
function zip(a, b) {
var arr = [];
for (var key in a) arr.push([a[key], b[key]]);
return arr;
}
console.log(zip('foo', 'bar'));
//=> [ [ 'f', 'b' ], [ 'o', 'a' ], [ 'o', 'r' ] ]
console.log(zip(['a', 'b', 'c'], ['x', 'y', 'z']));
@PurpleBooth
PurpleBooth / README-Template.md
Last active July 26, 2024 11:55
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@brennanMKE
brennanMKE / .bash_profile
Last active June 20, 2018 23:12
Open in Visual Studio Code
# Add the alias below to ~/.bash_profile on a Mac
# Save the file and run: source ~/.bash_profile
alias code='open $@ -a "Visual Studio Code"'
@yoavniran
yoavniran / ultimate-ut-cheat-sheet.md
Last active July 12, 2024 11:15
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
//run this in your console
for (var i = 0; i <= 3; i++) {
  setTimeout(function(){
    console.log(i); 
  }, 0); 
} 
@pbakondy
pbakondy / play.js
Last active June 7, 2021 22:08
Play with Object.prototype.toString.call()
// under Google Chrome 36
Object.prototype.toString.call([])
// "[object Array]"
Object.prototype.toString.call(function(){})
// "[object Function]"
Object.prototype.toString.call({})
// "[object Object]"
Object.prototype.toString.call(null)
// "[object Null]"
@danielbachhuber
danielbachhuber / gist:7126249
Last active December 21, 2021 15:46
Include posts from authors in the search results where either their display name or user login matches the query string
<?php
/**
* Include posts from authors in the search results where
* either their display name or user login matches the query string
*
* @author danielbachhuber
*/
add_filter( 'posts_search', 'db_filter_authors_search' );
function db_filter_authors_search( $posts_search ) {
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@artero
artero / launch_sublime_from_terminal.markdown
Last active May 15, 2024 03:38 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation