Skip to content

Instantly share code, notes, and snippets.

@lplume
lplume / README
Created May 21, 2018 11:00 — forked from bert/README
Bresenham Algorithms in C
Some possible implementations of the Bresenham Algorithms in C.
The Bresenham line algorithm is an algorithm which determines which points in an
n-dimensional raster should be plotted in order to form a close approximation
to a straight line between two given points.
It is commonly used to draw lines on a computer screen, as it uses only integer
addition, subtraction and bit shifting, all of which are very cheap operations
in standard computer architectures.
It is one of the earliest algorithms developed in the field of computer graphics.
A minor extension to the original algorithm also deals with drawing circles.
@lplume
lplume / starred_update.py
Last active April 30, 2018 07:07
Get updates from you starred repos
from sys import argv
from agithub.GitHub import GitHub
# pip install agithub
# argv[1] = github login name
## sample out
# repo: miyakogi/pyppeteer
@lplume
lplume / sample.js
Created January 24, 2018 10:44
Have a nice time
const str = "Something back";
say(str);
say(back(str));
<?php
define('ONE_WEEK', 604800); // 7 * 24 * 60 * 60
function number_of_days($days, $start, $end) {
$w = array(date('w', $start), date('w', $end));
$x = floor(($end-$start)/ONE_WEEK);
$sum = 0;
for ($day = 0;$day < 7;++$day) {
if ($days & pow(2, $day)) {
@lplume
lplume / es6clacn.js
Created August 21, 2017 15:37
es6 clog arrow clocknutes
let m=60000;let l="YYYY-MM-DDTHH:MM";let i=setInterval(() => console.log(parseInt(((new Date(l)) - (new Date)) / m)), m);
@lplume
lplume / example-cli.py
Created August 4, 2017 07:46 — forked from tomschr/example-cli-argparse.py
Template for an example CLI program with docopts and logging
#!/usr/bin/env python3
"""
Does some fancy stuff
Usage:
{proc} [-h | --help]
{proc} [-v ...] INPUT OUTPUT
Options:
-h, --help Shows this help
@lplume
lplume / pluck.js
Created April 5, 2017 06:53 — forked from kevincennis/pluck.js
Karplus-Strong with Web Audio API
function Pluck( ctx ) {
this.sr = ctx.sampleRate;
this.pro = ctx.createScriptProcessor( 512, 0, 1 );
this.pro.connect( ctx.destination );
}
Pluck.prototype.play = function( freq ) {
var N = Math.round( this.sr / freq ),
impulse = this.sr / 1000,
y = new Float32Array( N ),
/dir
- test.php
/lib
- fontparse.php
/ Font Parses
#test.php
<?php
@lplume
lplume / palindrome.py
Last active December 19, 2015 09:39
italian palindrome sentence check (switch accent sugar)
import sys
# TODO: input like "a'a'"
f = sys.argv[1].replace(" ","").lower()
o = f.find("'")
if o > 0:
r = (f[:o-1]+f[o-1:o+1][::-1]+f[o+1:])
else:
r = f
<?php
/**
* Convert a phrase to a SEO friendly uri (slug).
*
* @param string $title Phrase to convert
* @param string $separator Word separator
* @param boolean $ascii_only Transliterate to ASCII?
* @return string
*/
function make_slug($title, $separator = '-', $ascii_only = true) {