Skip to content

Instantly share code, notes, and snippets.

Jonathan M. Hethey JonathanMH

View GitHub Profile
@JonathanMH
JonathanMH / mdclip.go
Created May 3, 2017
Golang script for compiling markdown to HTML and copying to the clipboard
View mdclip.go
package main
import (
"log"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
@JonathanMH
JonathanMH / index.js
Created Oct 22, 2016
JSON Web Token Tutorial: Express
View index.js
// file: index.js
var _ = require("lodash");
var express = require("express");
var bodyParser = require("body-parser");
var jwt = require('jsonwebtoken');
var passport = require("passport");
var passportJWT = require("passport-jwt");
@JonathanMH
JonathanMH / employee.csv
Last active Jan 15, 2016
newline problem with node-csv-parse
View employee.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 5 columns, instead of 6. in line 1.
Name,Gender,"preferred language",startDate,endDate
Barbara McFinley,Female,JavaScript,2015-13-01,,
@JonathanMH
JonathanMH / crawl.js
Created Dec 14, 2015
crawl a page a bunch of times
View crawl.js
var fs = require('fs');
var async = require('async');
var request = require('request');
var cheerio = require('cheerio');
var _ = require('lodash');
var url = 'http://programmingexcuses.com';
var excuses = [];
@JonathanMH
JonathanMH / get-xml.js
Created Nov 8, 2015
XML parsing and filtering
View get-xml.js
var request = require('request');
var async = require('async');
var xml2js = require('xml2js');
var parseString = require('xml2js').parseString;
var parser = new xml2js.Parser(
{
preserveChildrenOrder: true,
explicitArray: false,
charkey: "content",
@JonathanMH
JonathanMH / create-conflict.sh
Created Jun 24, 2015
Create a merge conflict in git
View create-conflict.sh
#!/bin/bash
mkdir git-repo
cd git-repo
git init
touch my_code.sh
git add my_code.sh
echo "echo Hello" > my_code.sh
git commit -am 'initial'
git checkout -b new_branch
echo "echo \"Hello World\"" > my_code.sh
@JonathanMH
JonathanMH / md2pdf
Created Apr 12, 2015
markdown 2 pdf
View md2pdf
#!/bin/bash
filename=$1
basename=`basename $1 .md`
markdown-pdf $1 -o $basename.pdf -s /home/geronimo/Dropbox/templates/style.css
@JonathanMH
JonathanMH / 50-shades-of-grey.js
Last active Aug 29, 2015
50 Shades of Grey with CSS and JavaScript
View 50-shades-of-grey.js
var colour = '';
for (var i = 250; i > 0; i = i - 5) {
colour = 'background-color: rgb(' + i + ',' + i + ',' + i + ')';
console.log(colour);
document.write('<div style="float: left;margin: 5px; width:90px;height:30px;' + colour+ '"></div>');
}
@JonathanMH
JonathanMH / 51-android.rules
Created Sep 10, 2013
android dev rules for linux
View 51-android.rules
######################################################
# Project: http://code.google.com/p/51-android/ #
# File: /etc/udev/rules.d/51-android.rules #
# Author: snowdream <yanghui1986527@gmail.com> #
# Date: 2010.06.07 #
######################################################
#Acer
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0660", OWNER="snowdream"
@JonathanMH
JonathanMH / float.html
Created Aug 14, 2013
simple html float example with cat content
View float.html
<!DOCTYPE html>
<html>
<head>
<title>Float</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<style>
.left {
width: 300px;
float: left;
You can’t perform that action at this time.