Skip to content

Instantly share code, notes, and snippets.

View puppybits's full-sized avatar

Bobby puppybits

View GitHub Profile
@piotr-yuxuan
piotr-yuxuan / .md
Created August 20, 2020 21:40
Load a standalone Clojure library from a GitHub repository

Download from private GitHub Packages

Add this server in ~/.m2/settings.xml:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
@puppybits
puppybits / Behavior Science Terms.md
Last active November 12, 2017 16:38
Behavior Science Terms

anchoring

A cognitive bias that describes the common human tendency to rely too heavily on the first piece of information offered (the "anchor") when making decisions.

asymmetric dominance

The phenomenon whereby consumers will tend to have a specific change in preference between two options when also presented with a third option that is inferior in all respects to one option; but, in comparison to the other option, it is inferior in some respects and superior in others. A higher percentage of consumers will prefer the dominating option than when the asymmetrically dominated option is absent. (starts with a)

choice architecture

@Peeja
Peeja / logged-parser.cljs
Created September 24, 2016 16:28
Om Next parser middleware that adds logging for debugging
(defn logged-parser [parser]
(fn [env query target]
(js/console.groupCollapsed "parser:" (if target (str "(" target ")") ""))
(js/console.trace)
(js/console.debug (with-out-str (pprint query)))
(let [ret (parser env query target)]
(js/console.debug (with-out-str (pprint ret)))
(js/console.groupEnd)
ret)))
@Peeja
Peeja / rerender.cljs
Created September 9, 2016 23:00
What it appears to take to re-render the React tree when Figwheel reloads.
;; Re-render when Figwheel reloads.
(gevents/listen js/document.body
"figwheel.js-reload"
(fn []
(let [root-component (om-next/app-root (compassus/get-reconciler a))]
(letfn [(js-vals [o]
(map #(aget o %) (js-keys o)))
;; Finds the children of a React internal instance of a component.
;; That could be a single _renderedComponent or several
;; _renderedChildren.
@swannodette
swannodette / spec.cljs
Last active March 5, 2018 23:24
om.next query spec
(ns om.next.spec
(:require [cljs.spec :as s]))
(s/def ::ident (s/and vector? (s/cat :ident keyword? :value #(not (coll? %)))))
(s/def ::join-key (s/or :prop keyword? :ident ::ident))
(s/def ::join (s/and (s/map-of ::join-key ::query) #(= (count %) 1)))
(s/def ::union (s/and (s/map-of keyword? ::query) #(> (count %) 1)))
(s/def ::param-expr
(s/cat :query-expr ::query-expr
@ricardopereira
ricardopereira / GradientLayer + Mask + TableView.swift
Last active July 19, 2023 16:59
Apply vertical mask alpha gradient to UITableView
let gradient = CAGradientLayer()
gradient.frame = tableView.superview?.bounds ?? CGRectNull
gradient.colors = [UIColor.clearColor().CGColor, UIColor.clearColor().CGColor, UIColor.blackColor().CGColor, UIColor.blackColor().CGColor, UIColor.clearColor().CGColor, UIColor.clearColor().CGColor]
gradient.locations = [0.0, 0.15, 0.25, 0.75, 0.85, 1.0]
tableView.superview?.layer.mask = gradient
tableView.backgroundColor = UIColor.clearColor()
@zmmbreeze
zmmbreeze / stringify.js
Created March 7, 2014 09:13
json stringify can deal with circular reference
// http://stackoverflow.com/questions/11616630/json-stringify-avoid-typeerror-converting-circular-structure-to-json/11616993#11616993
var o = {};
o.o = o;
var cache = [];
JSON.stringify(o, function(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
@BennettSmith
BennettSmith / ..build-protbuf-2.5.0.md
Last active October 15, 2022 18:41
Script used to build Google Protobuf 2.5.0 for use with Xcode 5 / iOS 7. Builds all supported architectures and produces a universal binary static library.

Google Protobuf 2.5.0 - Mac OS X and iOS Support

The script in this gist will help you buid the Google Protobuf library for use with Mac OS X and iOS. Other methods (such as homebrew or direct compilation) have issues that prevent their use. The libraries built by this script are universal and support all iOS device architectures including the simluator.

Get the Script

The easiest way to use this script is to simply clone the gist onto your

@fupslot
fupslot / gist:5015897
Created February 22, 2013 19:23
Javascript: Convert base64 to a Blob
function dataURItoBlob(dataURI, callback) {
// convert base64 to raw binary data held in a string
// doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
var byteString = atob(dataURI.split(',')[1]);
// separate out the mime component
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
// write the bytes of the string to an ArrayBuffer
var ab = new ArrayBuffer(byteString.length);
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 19, 2024 11:00
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: