Skip to content

Instantly share code, notes, and snippets.

View kevinpeno's full-sized avatar
🏠
Working from home

Kevin Peno kevinpeno

🏠
Working from home
View GitHub Profile
/**
* Hack to allow jQuery to work within XHTML documents that define an xmlns
*/
/**
* Use the given object to override the given methods in its prototype
* with namespace-aware equivalents
*/
function addNS(obj, methods) {
var proto = obj.constructor.prototype;
@kevinpeno
kevinpeno / gist:1128700
Created August 5, 2011 22:38
SQL to get all recipes that contain all ingredients the user has
CREATE VIEW view_recipe_by_ingredient AS
SELECT R.*, RI.liquorID -- Replace R.* with columns in recipes table
FROM recipes R
JOIN recipeIngredients RI ON RI.recipeID = R.id;
CREATE VIEW view_recipes_in_cabinet AS
SELECT L.userID, RbI.id, COUNT( RbI.liquorID ) as LiquorCount, RbI.* -- Replace RbI.* with remaining columns in view_recipe_by_ingredient
FROM view_recipe_by_ingredient RbI
LEFT JOIN liquorCabinet L USING( liquorID );
@kevinpeno
kevinpeno / Schema.sql
Created August 6, 2011 04:39 — forked from SnugglePilot/gist:1128882
Sample Data for SQL Ingredient Selection
-- ----------------------------
-- Table structures
-- If using MySQL, update each table definition to use INNODB or foreign keys will be pointless
-- Example:
-- CREATE TABLE "Ingredient" (
-- "name" TEXT NOT NULL,
-- PRIMARY KEY ("name" ASC)
-- ) type INNODB;
-- ----------------------------
CREATE TABLE "Ingredient" (
@kevinpeno
kevinpeno / gist:1483362
Created December 15, 2011 22:56
Test various key/value "array" type systems in PHP
<?php
# Normal array
$startMemory = memory_get_usage();
$array = range( 1, 100000 );
echo ( ( memory_get_usage() - $startMemory ) / 100000 ), " bytes per element\n";
unset( $array, $startMemory );
# stdClass as a simple map/dictionary
$startMemory = memory_get_usage();
$array = new stdClass();
@kevinpeno
kevinpeno / gist:4735834
Created February 8, 2013 01:24
Testing whether object tag could be used to hack fallback support for webp in browsers that don't support it.
<!DOCTYPE html>
<html>
<head>
<title>A test for using object for webp</title>
</head>
<body>
<object data="https://www.gstatic.com/webp/gallery3/1_webp_ll.webp" type="image/webp">
<img src="https://www.gstatic.com/webp/gallery3/1.png"/>
</object>
</body>

Keybase proof

I hereby claim:

  • I am kevinpeno on github.
  • I am kevinpeno (https://keybase.io/kevinpeno) on keybase.
  • I have a public key whose fingerprint is DE6F C511 90B6 4EB5 7DE3 327B 5E1A FAC9 047F 2E25

To claim this, I am signing this object:

@kevinpeno
kevinpeno / gist:a836df0afca7236d92e3
Created April 14, 2015 21:39
Can't import built-in objects?
// Can't import built-in modules? :(
const {abs, pow} = Math
/*
ES2015 fat arrow noop
*/
() => {}
/*
My fat arrow noop
*/
14.2: Arrow Function Definitions
ArrowFunction[In, Yield] :
ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In]
ArrowParameters[Yield] :
FormalParameters[?Yield]
StrictFormalParameters[?Yield]
CoverParenthesizedExpressionAndArrowParameterList[?Yield]
@kevinpeno
kevinpeno / derp.md
Last active June 26, 2017 18:44
Hope you've had your coffee.

Hope you've had your coffee. I'm trying to figure out why this works:

state.map((good) => {
	if ( good.type === type ) {
		return _.assign(good, { amount })
	}
	else {
		return good
	}
})