Skip to content

Instantly share code, notes, and snippets.

View uniphil's full-sized avatar

phil uniphil

View GitHub Profile
@Holger-Will
Holger-Will / flatten.js
Created July 18, 2018 06:22
convert an svg path to line segments
function flatten(path,num){
var l = path.getTotalLength()
var p = path.getPointAtLength(0)
var d = `M${p.x} ${p.y}`
for(var i = (l/num);i<=l;i+=(l/num)){
p = path.getPointAtLength(i)
d+=`L${p.x} ${p.y}`
}
path.setAttribute("d",d+"z")
}
@Nothing4You
Nothing4You / letsencrypt_notes_openbsd.sh
Last active June 19, 2023 13:16 — forked from lachesis/letsencrypt_notes.sh
Set up LetsEncrypt using acme.sh without root on OpenBSD
# Modified for OpenBSD
# Assumes being root
# Requires curl to be installed, wget can also be used, relevant commands need to be adjusted. acme.sh supports both.
# Configured to use Cloudflare DNS for verification
# How to use "acme.sh" to set up Lets Encrypt without root permissions
# See https://github.com/Neilpang/acme.sh for more
# This assumes that your website has a webroot at "/var/www/<domain>"
# I'll use the domain "EXAMPLE.com" as an example
@gbaman
gbaman / HowToOTGFast.md
Last active May 14, 2024 10:26
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)

More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH i

@conorhastings
conorhastings / test.js
Created November 9, 2015 05:35
Bad JSX highlighting
import React, { Component } from 'react';
class Test extends Component {
render() {
return (
<div>
Wowowow ' this is fun
</div>
);
}
@Korko
Korko / gist:ec8f808a373b17cb96f0
Created February 6, 2015 12:54
Print list of git authors with total added lines, total removed lines, total lines really added and percent of participation over added lines
git shortlog -s | cut -f2 | while read a; do git log --author="$a" --pretty=tformat: --numstat | awk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { print "'"$a"',"add","subs","loc }'; done | awk '{ print; split($0,a,","); total += a[2] } END { print "Total,"total",0,"total }' | sort -nrk2 -t',' | while read l; do a=`echo $l | cut -d',' -f1`; if [ "$a" == "Total" ]; then t=`echo $l | cut -d',' -f2`; fi; mt=`echo $l | cut -d',' -f2`; echo $l","`awk 'BEGIN { printf("%d", '$mt'/'$t'*100) }'`; done | tail -n +2
@sidequestboy
sidequestboy / alphabetize.py
Created May 17, 2014 02:04
Finding Fixed Points of the Lexicographic ordering of the Phonetic English Alphabet
#!/usr/bin/python
from collections import OrderedDict
conventional_alphabet = list('abcdefghijklmnopqrstuvwxyz')
conventional_phonetic = ['a', 'bee', 'cee', 'dee', 'e', 'ef', 'gee', 'aitch',
'i', 'jay', 'kay', 'el', 'em', 'en', 'o', 'pee',
'cue', 'ar', 'es', 'tee', 'u', 'vee', 'doubleu', 'ex',
'wye', 'zed']
def lexi(letters):
@branneman
branneman / better-nodejs-require-paths.md
Last active June 29, 2024 16:00
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

class XAccelMiddleware(object):
"""A WSGI Middleware that converts X-Sendfile headers to X-Accel-Redirect
headers if possible.
If the path is not mapped to a URI usable for X-Sendfile we abort with an
error since it likely means there is a misconfiguration.
"""
def __init__(self, app, mapping):
self.app = app
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: