Skip to content

Instantly share code, notes, and snippets.

View sphvn's full-sized avatar

Stephen Underwood sphvn

  • San Francisco, California
  • 11:10 (UTC -07:00)
View GitHub Profile
@sphvn
sphvn / traverse.js
Last active October 26, 2023 21:49
Recursively traverse object javascript, recurse json js, loop and get key/value pair for JSON
var traverse = function(o, fn) {
for (var i in o) {
fn.apply(this,[i,o[i]]);
if (o[i] !== null && typeof(o[i])=="object") {
traverse(o[i], fn);
}
}
}
// usage
@sphvn
sphvn / icyveins2atlasloot
Last active April 19, 2023 19:53
Pulling item ID's from wowhead.com / icyveins best in slot lists into the atlasloot import format
var qs = x => document.querySelector(x);
var qsa = (x, y) => x.querySelectorAll(y)
var toArr = x => Array.prototype.slice.call(x);
var elemId = ".bis_table";
var itemSlot = "span a";
toArr(qsa(qs(elemId), itemSlot))
.map(x => x.href)
.map(x => x.split('=')[1])
var upgradeList = document.querySelector("#panelUpgList"); var upgradeItems = upgradeList.querySelectorAll(".o-upg-item:not(.hidden)") var upgradeIds = Array.from(upgradeItems).map(function(x){ return "i:" + x.dataset.uniqueId; }) upgradeIds.join();
@sphvn
sphvn / atlasloot-classic-warlock-phase-five-5-bis-list
Last active July 4, 2020 01:20
BiS lists for use with atlasloot favourites / lists
i:21337,i:21608,i:21335,i:22731,i:19682,i:21186,i:21622,i:21597,i:21603,i:21585,i:22730,i:19683,i:19684,i:21417,i:21709,i:18820,i:19379
@sphvn
sphvn / branch-switching.md
Last active June 19, 2018 18:11
branch switching
# Day Four in Node for fun
# http://adventofcode.com/2017/day/4/
require! "fs"
require! 'prelude-ls': {lines, words, zip, map, filter, unique}
length = (.length)
sort = (.split('').sort().join(''))
input = map words, lines (fs.read-file-sync "input.txt", 'utf-8')
sorted = map ((x) -> map ((y) -> sort y), x), input
// Generated by LiveScript 1.4.0
// prelude.ls 1.1.2
// Copyright (c) George Zahariev
// Released under the MIT License
// https://raw.githubusercontent.com/gkz/prelude-ls/master/LICENSE
require=function n(r,t,e){function u(o,a){if(!t[o]){if(!r[o]){var c=typeof require=="function"&&require;if(!a&&c)return c(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=t[o]={exports:{}};r[o][0].call(f.exports,function(n){var t=r[o][1][n];return u(t?t:n)},f,f.exports,n,r,t,e)}return t[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<e.length;o++)u(e[o]);return u}({1:[function(n,r,t){
// Generated by LiveScript 1.4.0
var e,u,i,o,a,c,f=[].slice,l={}.toString;e=s(function(n,r){return n.apply(null,r)});u=function(n){return s(n)};i=s(function(n,r,t){return n(t,r)});o=function(n){return function(r){return function(){return n(r(r)).apply(null,arguments)}}(function(r){return function(){return n(r(r)).apply(null,arguments)}})};a=s(function(n,r,t,e){return n(r(t),r(e))});c=function(n){va
// FB curl example
// curl \
// -F 'pixel_id=<PIXEL_ID>' \
// -F 'name=My New Website Custom Audience' \
// -F 'subtype=WEBSITE' \
// -F 'retention_days=15' \
// -F 'rule={"url":{"i_contains":"shoes"}}' \
// -F 'prefill=1' \
// -F 'access_token=<ACCESS_TOKEN>' \
// https://graph.facebook.com/v2.7/act_<AD_ACCOUNT_ID>/customaudiences
@sphvn
sphvn / Main.hs
Last active February 10, 2016 08:03
Example of using Haskell Snap for File / Directory Serving with Routes.
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.HashMap.Strict as H
import qualified Data.ByteString.Char8 as C
import Control.Applicative ((<|>))
import Snap.Core
import Snap.Util.FileServe
import Snap.Http.Server (quickHttpServe)
import Snap.Util.GZip (withCompression)
@sphvn
sphvn / nyanicon.js
Created November 21, 2011 06:32
Animooted Nyan Favicon
// *** First of all the Favicon.js, Favicon.js - [http://ajaxify.com/run/favicon] ***
var favicon = {
defaultPause: 500,
change: function(iconURL, optionalDocTitle) {
clearTimeout(this.loopTimer);
if (optionalDocTitle) {
document.title = optionalDocTitle;
}
this.addLink(iconURL, true);
},