Skip to content

Instantly share code, notes, and snippets.

@Wizek
Wizek / decision.user.js
Last active May 14, 2016 09:38
Advanced Pro-Con Decision helper for WorkFlowy; decision, workflowy, score summary, hierarchical data binding, searches for matching {{ decisionCount(children) }}, with radius and confidence%
// ==UserScript==
// @name Advanced Pro-Con Decision helper for WorkFlowy
// @description If you write `{{ decisionCount(children) }}` somewhere, this script will sum up `(+)`s, `(-)`s `(+2.3)`s and similar in all children, helping you weigh pros vs cons.
// @match https://workflowy.com/*
// @version v0.3.1
// @grant none
// @namespace https://gist.github.com/Wizek/d35c16ec23bff0dd2fb1
// @downloadURL https://gist.github.com/Wizek/d35c16ec23bff0dd2fb1/raw/decision.user.js
// @require https://cdnjs.cloudflare.com/ajax/libs/ramda/0.17.1/ramda.min.js
@nh2
nh2 / hspec-before-all.hs
Created August 12, 2015 17:43
Example of ignoring hspec's beforeAll hook context
import Control.Concurrent (threadDelay)
import Test.Hspec
import qualified Test.Hspec.Core.Hooks as Hooks
main :: IO ()
main = hspec spec
-- | When a hook is set up with `beforeAll`, that changes the type
@katemonkeys
katemonkeys / gist:e17580777b57915f5068
Last active April 27, 2025 23:40
Everything Wrong With The Withings API

Top Six Things You Need To Know About The Withings API*

*where “you” is probably a developer, or at least a strange user

I should preface this by saying that I got a Withings Smart Body Analyzer for Christmas last year and I’ve been generally happy with it. It purports to be able to take my heart rate through my bare feet and that seems not to work for my physiology, but overall I’m a fan. If if their Wikipedia page is to be believed they are having a pretty rad impact on making the Quantified Self movement more for normal people and they only have 20 full time employees. Also they try hard to use SI units, which I can get behind. Anyway, on to the rant.

I originally called this post “Everything wrong with the Withings API” and I meant it. For every useful field I can extract from their “award winning” app, I have spent an hour screaming at the inconsistencies in their implementation or inexplicable holes in their data

@carymrobbins
carymrobbins / ManualKey.hs
Last active May 2, 2017 23:58
Yesod - manually creating a Key
-- Good
import Database.Persist.Sql
toSqlKey 1 :: UserId
-- Bad
Prelude.read "UserKey {unUserKey = SqlBackendKey {unSqlBackendKey = 1}}" :: UserId
@edwinb
edwinb / divide.idr
Created July 2, 2014 09:44
Type safe division
module Main
{- Divide x by y, as long as there is a proof that y is non-zero. The
'auto' keyword on the 'p' argument means that when safe_div is called,
Idris will search for a proof. Either y will be statically known, in
which case this is easy, otherwise there must be a proof in the context.
'so : Bool -> Type' is a predicate on booleans which only holds if the
boolean is true. Essentially, we are making it a requirement in the type
that a necessary dynamic type is done before we call the function -}
@jakub-g
jakub-g / git-diff-stat-sort.sh
Last active July 20, 2024 09:17
sort git diff --stat starting from the files that have most lines changed
git show HEAD --stat=200 | tail +7 | awk '{ print $3 " "$4 " " $1}' | sort -n -r | less
@katowulf
katowulf / firebase_copy.js
Last active July 29, 2022 15:58
Move or copy a Firebase path to a new location
function copyFbRecord(oldRef, newRef) {
oldRef.once('value', function(snap) {
newRef.set( snap.value(), function(error) {
if( error && typeof(console) !== 'undefined' && console.error ) { console.error(error); }
});
});
}
@Wizek
Wizek / logFactory.js
Last active October 11, 2015 20:58
Superpowered logging for AngularJS
// Superpowered logging for AngularJS.
angular.module('logFactory', ['ng'])
.value('logFactory_whiteList', /.*/)
//.value('logFactory_whiteList', /!|.*Ctrl|run/)
.value('logFactory_piercingMethods', {warn:true, error:true})
.factory('logFactory', ['$log', 'logFactory_whiteList' , 'logFactory_piercingMethods', function ($log, whiteList, piercing) {
piercing = piercing || {}
@Wizek
Wizek / objectSyntax.js
Created February 18, 2012 10:29
JS Object literal syntax
/*\
* Journey in search of the most beautiful and
* most usable JavaScript object literal syntax.
\*/
/*\
* Traditional, AKA how fast can you find a missing comma?
\*/
var temp = {
Baar: 1,
foo
(
function( ) {
return bar(
'foo' ) ;
},
function
()
{
return 'bar'