Skip to content

Instantly share code, notes, and snippets.

View copperwall's full-sized avatar
j chillin

Chris Opperwall copperwall

j chillin
View GitHub Profile
const { IncomingWebhook } = require('@slack/client');
// Needs to be run on Node 8.10 or later.
exports.handler = async (event) => {
// Could pass this through an environment variable
// so it's usable across different slack webhooks.
const URL = "https://hooks.slack.com/services/<YOUR_WEBHOOK_URL>";
const webhook = new IncomingWebhook(URL);
let location;
@copperwall
copperwall / Dockerfile
Last active October 21, 2018 21:37
Alpine based quassel image
FROM alpine:latest
RUN apk update && apk add quassel-core sqlite qt-sqlite
EXPOSE 4242
ENTRYPOINT ["quasselcore", "--configdir=/var/lib/quassel"]
@copperwall
copperwall / Dockerfile
Last active August 16, 2018 00:28
Ubuntu based quassel image
FROM ubuntu:latest
RUN apt-get update && apt-get -y install quassel-core
EXPOSE 4242
ENTRYPOINT ['quasselcore', '--configdir=/var/lib/quassel']
async function api() {
const res = await fetch('/api/2.0/guides');
return res.json();
}
function *api() {
const res = yield fetch('/api/2.0/guides');
return res.json();
async function api() {
const res = await fetch("/api/2.0/guides");
const json = await res.json();
return json
}
async function getGuides() {
let results = [];
function *example() {
const first = yield 1;
const second = yield 2;
console.log(first);
console.log(second);
}
const gen = example();
@copperwall
copperwall / defstruct.clj
Created June 9, 2018 22:48
Super tiny defstruct macro that creates constructor and access methods
;; I remember racket having something like this, where you'd magically
;; have accessor functions defined for any structs you defined.
;;
;; I thought it might be fun to recreate that in Clojure after getting
;; through Ch. 9 Macros in Clojure for the Brave and True.
(defmacro defstruct
"Defines a struct type and accessor functions for its fields"
[name & field-params]
`(do
@copperwall
copperwall / query-param-parser.cljs
Created May 26, 2018 03:06
Query Parameter Parser in ClojureScript
(defn upgradeToVector [x] (if (vector? x) x (vector x)))
(defn makeParams [paramStr] (.split paramStr "&"))
(defn makePairs [param]
(let [[key value] (.split param "=")]
(vector key value)))
(defn parseParamString [paramStr]
(reduce (fn [result [key value]]
(if (contains? result key)
/**
* Consumes a Cheerio Element and returns a function that
* consumes a category guid and returns the text value associated with it.
*/
const getStatNameFromDropdown = compose(curry(guidToText), cheerio);
/**
* Given a container element, grab all career stats data from its children.
* @param {Cheerio Element} playtypeContainer
*/
/**
* Consumes a Cheerio Element and returns a function that
* consumes a category guid and returns the text value associated with it.
*/
const getStatNameFromDropdown = compose(curry(guidToText), cheerio);
/**
* Given a container element, grab all top hero stats data from its children.
* @param {Cheerio Element} playtypeContainer Can either be the quickplay or competitive container.
*/