Skip to content

Instantly share code, notes, and snippets.

View sclark39's full-sized avatar

Skyler Clark sclark39

View GitHub Profile
@sclark39
sclark39 / day4.js
Last active December 4, 2017 23:04
Solution to the Advent of Code 2017 Day 4
// var passphrases = input.split('\n')
function countValid( passphrases, allowAnagrams )
{
return passphrases.reduce( (s,passphrase) => {
var passwords = passphrase.split(' ')
passwords = allowAnagrams ? passwords : passwords.map( a => ( a.split('').sort().join('') ) )
return s + passwords.reduce( ( s,n,i,a ) => s && a.indexOf(n) == i )
}, 0 )
}
@sclark39
sclark39 / InstagramIdConvert.js
Last active September 24, 2024 15:11
Convert from Instagram Shortcode to Id and Back using big-integer
var bigint = require( 'big-integer' )
var lower = 'abcdefghijklmnopqrstuvwxyz';
var upper = lower.toUpperCase();
var numbers = '0123456789'
var ig_alphabet = upper + lower + numbers + '-_'
var bigint_alphabet = numbers + lower
function toShortcode( longid )
@sclark39
sclark39 / hotload.js
Created October 7, 2017 17:39
Endless loop, re-runs code every time file change is detected.
var co = require('co')
var Promise = require("bluebird")
var chokidar = require('chokidar')
var hotloadFile = 'hotload.js'
var watcher = chokidar.watch( hotloadFile )
function waitForHotload()
{
return new Promise( (fulfill, reject) => watcher.once( 'change', fulfill ) )
@sclark39
sclark39 / co-scheduler.js
Created September 25, 2017 14:31
This scheduler allows you to run multiple co "threads" that can yield and do async actions without being interrupted until explicitly declared.
var co = require('co')
var scheduler =
{
queue : []
}
// Requests control from scheduler
scheduler.promote = function()
{
@sclark39
sclark39 / gist:7c4eaeabd6fc453c90c3b2eaed7126dc
Last active June 5, 2017 18:18
Redstone Superflat World
Superflat Preset:
3;1*minecraft:bedrock,50*minecraft:stained_hardened_clay:9,1*minecraft:concrete:13;1;
/gamerule commandBlockOutput false
/gamerule doMobSpawning false
/gamerule doWeatherCycle false
/gamerule doDaylightCycle false
/time set 4284
@sclark39
sclark39 / fishingrod.command_block
Created June 5, 2017 14:12
Creates an auto-refilling chest with a enchanted fishing rod
/blockdata ~0 ~1 ~0 {Items:[
{id:fishing_rod,Slot:0,Count:1,tag:{ench:[{id:34,lvl:6},{id:61,lvl:3},{id:62,lvl:5}]}}
]}
@sclark39
sclark39 / analog_shulker.command_block
Last active June 5, 2017 14:13
Minecraft Color Coded Signal Strength Shulker Boxes
/blockdata ~0 ~1 ~0 {Items:[
{id:brown_shulker_box,Slot:0,Count:1,tag:{display:{Name:"Signal Strength 1"},
BlockEntityTag:{Items:[
{Slot:4,id:redstone_block,Count:21b},
{Slot:13,id:redstone_block,Count:21b},
{Slot:22,id:redstone_block,Count:21b}
]}}},
{id:red_shulker_box,Slot:1,Count:1,tag:{display:{Name:"Signal Strength 2"},
BlockEntityTag:{Items:[
{Slot:3,id:redstone_block,Count:21b},
// Define the routes, which we will procedurally load
const routes =
{
get: // body data not allowed in GET
[
{ path: '/', action: 'HelloWorld' },
{ path: '/http', action: 'TestHTTP' },
{ path: '/echo', action: 'EchoRequest' },
]
}
private func makeRequest(
method : String, url : String,
query : [String:Any]! = nil,
body : [String:Any]! = nil,
complete: @escaping DatabaseAsyncCallback
)
{
let client = WOMAPIGatewayClient.default()
/*
Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License").
You may not use this file except in compliance with the License.
A copy of the License is located at
http://aws.amazon.com/apache2.0
or in the "license" file accompanying this file. This file is distributed