Skip to content

Instantly share code, notes, and snippets.

View stpettersens's full-sized avatar

Sam Saint-Pettersen stpettersens

View GitHub Profile
@stpettersens
stpettersens / chrome_extensions.md
Last active August 15, 2016 22:35
Good Chrome/Vivaldi extensions and user scripts.

Chrome/Vivaldi extensions:

  • IP Whois & Flags Chrome & Websites Rating
  • Google Mail Checker
  • Send from Gmail (by Google)
  • Mailto: for Gmail™
  • Google Input Tools
  • PrettyPrint
  • XML Tree
  • JSONView
@stpettersens
stpettersens / atom_packages.md
Last active July 6, 2016 09:18
Packages to install on Atom.

Packages to install on Atom:

  • atom-jade
  • atom-handlebars
  • atom-typescript
  • language-typescript-grammars-only
  • language-rust
  • language-docker
  • language-ignore
  • color-picker
@stpettersens
stpettersens / startt.cmd
Created March 27, 2016 13:13
Start new window process wrappers
start %*
@stpettersens
stpettersens / ogg-server.js
Created March 20, 2016 18:28
Server which listens for PCM stream and outputs a Ogg Vorbis file (doesn't work yet).
'use strict';
const ogg = require('ogg');
const vorbis = require('vorbis');
const BinaryServer = require('binaryjs').BinaryServer;
let server = BinaryServer({port: 8080});
let oe = new ogg.Encoder();
let ve = new vorbis.Encoder();
let out = null;
@stpettersens
stpettersens / wav-server.js
Created March 20, 2016 18:25
Server which listens for PCM stream and outputs a WAVE file.
'use strict';
const wav = require('wav');
const BinaryServer = require('binaryjs').BinaryServer;
let server = BinaryServer({port: 8080});
let out = null;
server.on('connection', function(client) {
client.on('stream', function(stream, meta) {
@stpettersens
stpettersens / wrap.js
Created January 24, 2016 15:49
Wrap function (@mdjasper).
/*
Michael Jasper's (@mdjasper) wrap DOM element function.
From: http://www.mikedoesweb.com/2014/wrapping-an-element-in-vanilla-javascript/
*/
function wrap(top, selector, bottom){
var matches = document.querySelectorAll(selector);
for (var i = 0; i < matches.length; i++){
var modified = top + matches[i].outerHTML + bottom;
matches[i].outerHTML = modified;
}
@stpettersens
stpettersens / Dockerfile
Last active August 14, 2017 20:33
Dockerfile for container that provides MongoDB + Node.js.
#
# Dockerfile for a container that provides Node.js and MongoDB.
# saintpettersens/nodemongodb
#
# Use Ubuntu as base for container.
FROM ubuntu
# Install MongoDB.
ENV mongorepo "http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse"
@stpettersens
stpettersens / Caddyfile
Last active November 20, 2015 14:33
Wrapper script for Caddy server (shell script and Caddyfile to use with it).
# Serve to outside world on port 2015.
0.0.0.0:2015
# This rewrite stops caddy.sh being served.
rewrite {
regexp caddy\.sh
to /
}
@stpettersens
stpettersens / long_string_formatter.html
Created August 5, 2015 23:42
Long string formatter tool
<script>
function format() {
var text = document.getElementById('formatter').value;
text = '\'' + text + '\''
i = 0
x = 1
var newText = '';
for(var i = 0; i < text.length; i++) {
if(x == 40) {
@stpettersens
stpettersens / base64_encoder.py
Created August 5, 2015 23:25
base64 encoder
import sys
import base64
with open(sys.argv[1], 'rb') as binary_file:
encoded_string = base64.b64encode(binary_file.read())
print(encoded_string)