Skip to content

Instantly share code, notes, and snippets.

View lisp-ceo's full-sized avatar
🎇
Key Contributor

James Meldrum lisp-ceo

🎇
Key Contributor
View GitHub Profile
@lisp-ceo
lisp-ceo / model.go
Created September 20, 2017 07:39
GORM
package sqlite
import (
"fmt"
"os"
"sync"
"time"
"github.com/golang/glog"
"github.com/jinzhu/gorm"
@lisp-ceo
lisp-ceo / Dockerfile
Created September 20, 2017 06:20
Isolated build environment
FROM golang:1.8
MAINTAINER [email protected]
RUN mkdir -p /go/src/github.com/maxwellforest/onefill
WORKDIR /go/src/github.com/maxwellforest/onefill
COPY . /go/src/github.com/maxwellforest/onefill
RUN go get -u github.com/golang/dep/cmd/dep
RUN dep ensure
@lisp-ceo
lisp-ceo / gist:a5de91aac50b8b3b0254cee56f3615ed
Created July 27, 2017 01:43
Synchronous execution of asynchronous function using async/await
#!/usr/bin/env node
let success = 'success';
let failure = 'failure';
var callCount = 0;
async function runSyncAsync() {
console.log('runSyncAsync');
let resCallCount = 0;
let success = 4;
@lisp-ceo
lisp-ceo / gist:03a2fc316e59515a06241f9d6b804ebf
Created July 27, 2017 00:48
What the fuck is this language even?
#!/usr/bin/env node
let success = 'success';
let failure = 'failure';
async function runEngine() {
console.log('runEngine');
var report = await run1();
return report; // Important! Otherwise it will return some bizarre object
// { '0': {},
@lisp-ceo
lisp-ceo / compressVideo.swift
Created July 17, 2017 06:02
Swift function to compress and multiple video and audio to H264
static func compressVideo(inputURL: URL, outputURL: URL) -> Promise<URL> {
let videoAsset = AVURLAsset(url: inputURL, options: nil)
return Promise<URL> { fulfill, reject in
guard let videoTrack = videoAsset.tracks(withMediaType: AVMediaTypeVideo).first else {
reject(AVServiceError.noDataFound)
return
}
guard let audioTrack = videoAsset.tracks(withMediaType: AVMediaTypeAudio).first else {
reject(AVServiceError.noDataFound)
return
@lisp-ceo
lisp-ceo / Blog.js
Created July 4, 2017 10:31
A stab at a Jekyll-based assembler for rendering Markdown in Vue.js templates
// TODO Copy over all support directories as well
// TODO Replace returning promises with async / await
// TODO Decide if it's worth making an extension to Vue.js
// TODO Decide how Markdown will interact with custom Vue.js components
// Global map of Markdown syntax to Vue.js components on a page-by-page basis with sane defaults?
// Unit testing, project setup and maintenance as an open source concern
#!/usr/bin/env node
var fs = require('fs');
@lisp-ceo
lisp-ceo / main.go
Created June 28, 2017 02:41
Testing a static file server deployment in Go
package main
// Simple static file server in go
// Usage:
// -p="6969": port to serve on
// -d="./static": the directory of static files to host
import (
"flag"
"log"
@lisp-ceo
lisp-ceo / sigterm-handler.go
Created May 4, 2017 00:54
Catching SIGTERM in Go
term := make(chan os.Signal, 1)
signal.Notify(term, os.Interrupt, syscall.SIGTERM)
<!DOCTYPE html>
<html lang="en">
<head>
<title>A File Upload Demo</title>
<style>
html, body {
height: 100%;
margin: 0;
}
body {
@lisp-ceo
lisp-ceo / prometheus.yml
Created November 24, 2016 00:29
Configuring slack hook for prometheus
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
alerting:
receivers:
- name: "slack"
slack_configs: