Skip to content

Instantly share code, notes, and snippets.

View dav-m85's full-sized avatar
🥖

David "baguette" Moreau dav-m85

🥖
View GitHub Profile
@dav-m85
dav-m85 / feedly_export_saved_for_later
Created August 16, 2022 20:43 — forked from bradcrawford/feedly_export_saved_for_later
Simple script that exports a users "Saved For Later" list out of Feedly as a JSON string
// Simple script that exports a users "Saved For Later" list out of Feedly
// as a JSON string.
//
// This was intended for use in the Google Chrome's "Inspector" tool so your
// mileage may vary if used in other contexts.
//
// Format of JSON is as follows:
// [
// {
// title: "Title",
@dav-m85
dav-m85 / extract.go
Created July 19, 2022 08:12
Extract to be translated literals from go templates
//go:build ignore
// +build ignore
package main
import (
"flag"
"fmt"
"io/fs"
"io/ioutil"
@dav-m85
dav-m85 / main.go
Created April 26, 2022 20:20
Idiomatic Golang Subcommands
// Seen on https://stackoverflow.com/a/67905164
var (
required string
fooCmd = flag.NewFlagSet("foo", flag.ExitOnError)
barCmd = flag.NewFlagSet("bar", flag.ExitOnError)
)
var subcommands = map[string]*flag.FlagSet{
@dav-m85
dav-m85 / ticker.ts
Created December 14, 2021 19:11
A ticker class encapsulating setInterval
/**
* Usage:
* new Ticker(timeout: number, (stop: Function) => {
* // do stuff every timeout
* if (...) {stop()}
* })
*/
class Ticker {
private ticker: any
private handler: Function
@dav-m85
dav-m85 / main.go
Created September 19, 2021 10:19
Process .xbel files (XML Bookmark Exchange Language)
package main
import (
"encoding/xml"
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
)
@dav-m85
dav-m85 / keyboardInterrupt.c
Last active March 12, 2016 15:26
4x4 keypad with interrupt
// Arduino Uno source
int keyInterrupt = 2;
volatile int row = -1;
volatile int col = -1;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {}
@dav-m85
dav-m85 / gist:6226202
Created August 13, 2013 22:10
Extract Surface, Exchange and Agitation for SEO keywords
#!/bin/perl
# use warnings;
use Data::Dumper;
$num_args = $#ARGV + 1;
if ($num_args != 2) {
print "\nUsage: ./seokw.pl corpusA corpusB\n";
exit;
}
@dav-m85
dav-m85 / gist:5025485
Last active December 14, 2015 03:59
Work in progress, a php script to solve the trinomino line problem
<?php
function swap($array, $a, $b) {
if( empty($array) || !is_array($array) ){
return $array;
}
$j = count($array);
$ael = array($array[$a]);
$bel = array($array[$b]);
@dav-m85
dav-m85 / gist:4733329
Created February 7, 2013 19:12
Vector class along with a cool algorithm that... let me describe it. Say we want 100 items from 3 different sources, and we want with it different ratios from each. The sources arent perfect and sometimes we dont get enough item to match a ratio. This algorithm makes the other sources spit more items.
<?php
/**
* I rewrote quickly a Vector class, reinventing the wheel sorry :)
*/
class Vector implements arrayaccess{
private $_x = array();
public function offsetExists ( $offset ){
return isset($this->_x[$offset]);
}
public function offsetGet ( $offset ){