Skip to content

Instantly share code, notes, and snippets.

View rjhilgefort's full-sized avatar

Rob Hilgefort rjhilgefort

View GitHub Profile
@rjhilgefort
rjhilgefort / generateNines.php
Created June 1, 2013 03:18
Multiple ways to generate any number of nines (or any digit for that matter) via PHP
<pre>
<?php
//By @pkspencer
function generateNines_One($numNines)
{
$result = 0;
for ($i=0; $i < $numNines; $i++) {
$result += pow(10, $i);
}
@rjhilgefort
rjhilgefort / Readme.md
Last active November 9, 2022 22:17 — forked from mrgcohen/Readme.md

Requirements

  • bootstrap with typeahead
  • jquery

Explanation

This will use bootstrap with typeahead to create an autocomplete search.

@rjhilgefort
rjhilgefort / app-object.js
Last active August 29, 2015 14:09
Ember Object Property List Strategy
var AppObject = Ember.Object.extend({
/**
* Get a list of all computed properties set on this instance
*
* @method getComputedPropertyList
* @return {Array} List of computed properties (strings)
* @since TODO
*/
getComputedPropertyList: function() {
@rjhilgefort
rjhilgefort / init.lua
Last active May 19, 2017 03:10 — forked from arbelt/init.lua
Hammerspoon config to send escape on short ctrl press
local sendEscape = true
local ctrlKeyTimer = hs.timer.delayed.new(0.15, function()
sendEscape = false
end)
local lastMods = {}
local flagsChangedHandler = function(event)
local newMods = event:getFlags()
if lastMods.ctrl == newMods.ctrl then return false end
@rjhilgefort
rjhilgefort / personalizeCoupons.js
Created July 17, 2017 22:10
Coding Test: Personalize Coupons
// isCouponInCategories :: Array<Object> => Object -> Boolean
const isCouponInCategories = categories => coupon =>
categories.includes(coupon.category);
// percentDiscount :: Object -> Number
const percentDiscount = coupon =>
((coupon.couponAmount / coupon.itemPrice) * 100);
// TODO: I decided to remove the code after the list was reduced
// to the 10 coupons because of the "So in short" summary of
@rjhilgefort
rjhilgefort / validateCards.js
Created July 17, 2017 22:11
Coding Test: Validate Cards
// --- UTILS ------------------------------------------------
// pipe :: ...Functions => a -> b
const pipe = (...funcs) => data =>
funcs.reduce((acc, func) => func(acc), data);
// toNumber :: String -> Number
const toNumber = data => parseInt(data, 10);
// double :: Number -> Number
// NOTE: Ramda repl
console.clear()
const foo = [
{ id: 'one' },
{ id: 'two' },
{ id: 'three' },
]
// NOTE: Ramda repl
console.clear()
const foo = (a, b) => a + b
const bar = () => 4
const tryYolo = curry((func, params) => {
try {
return apply(func, params)
@rjhilgefort
rjhilgefort / class.js
Last active December 2, 2017 19:48
Class vs Factory
class ConsecutiveFailure {
constructor({
count = 0,
threshold = 10,
logger = console.log,
}) {
this.count = count;
this.threshold = threshold;
this.logger = logger;
}
@rjhilgefort
rjhilgefort / promise-utils.js
Last active January 7, 2019 22:51
Some utils to compose promise more easily.
console.clear()
///////////////////////////////////////////////////////////////
// promise-utils.js
// PromiseAll :: Promise.all
const PromiseAll = (x) => Promise.all(x)
// thenP :: Function -> Promise -> Promise
const thenP =