Skip to content

Instantly share code, notes, and snippets.

View ichpuchtli's full-sized avatar

Sam Macpherson ichpuchtli

View GitHub Profile
@ichpuchtli
ichpuchtli / flatMap.ts
Last active February 22, 2016 13:19 — forked from samgiles/flatMap.js
Javascript flatMap implementation
// [B](f: (A) ⇒ [B]): [B] ; Although the types in the arrays aren't strict (:
function flatMap<T, U>(array: T[], mapFunc: (x: T) => U[]) : U[] {
return array.reduce((cumulus: U[], next: T) => [...mapFunc(next), ...cumulus], <U[]> []);
}
@ichpuchtli
ichpuchtli / DumbPubSubStub.ts
Created November 21, 2015 09:22
A super dumb pub sub implementation
export interface PubSubCallback
{
(args?: any, topic?: any) : void;
}
interface PubSubTopicMap
{
[topic : string]: PubSubCallback[];
}
@ichpuchtli
ichpuchtli / lodash-response.js
Created October 6, 2015 08:20
lodash 3.7.0 minification failing with System.Web.Optimization
/* Minification failed. Returning unminified contents.
(19,462-469): run-time error JS1019: Can't have 'break' outside of loop: break n
*/
/**
* @license
* lodash 3.7.0 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
* Build: `lodash modern -o ./lodash.js`
*/
;(function(){function n(n,t){if(n!==t){var r=n===n,e=t===t;if(n>t||!r||n===w&&e)return 1;if(n<t||!e||t===w&&r)return-1}return 0}function t(n,t,r){for(var e=n.length,u=r?e:-1;r?u--:++u<e;)if(t(n[u],u,n))return u;return-1}function r(n,t,r){if(t!==t)return p(n,r);r-=1;for(var e=n.length;++r<e;)if(n[r]===t)return r;return-1}function e(n){return typeof n=="function"||false}function u(n){return typeof n=="string"?n:null==n?"":n+""}function o(n){return n.charCodeAt(0)}function i(n,t){for(var r=-1,e=n.length;++r<e&&-1<t.indexOf(n.charAt(r)););
return r}function f(n,t){for(var r=n.length;r--&&-1<t.indexOf(n.charAt(r)););return r}function a(t,r){return n(t.a,r.a)||t.b-r.b}function c(n){return $n[n]}function l(n){return Ln[n]}f
@ichpuchtli
ichpuchtli / README.md
Last active September 13, 2017 16:05
create_ap systemd service
@ichpuchtli
ichpuchtli / README.md
Last active July 16, 2021 20:12
nginx + uwsgi + flask on arch linux

Dependencies

$ pacman -Syu nginx uwsgi-plugin-python uwsgi python2-flask sqlite

Directory Overview

$ tree /srv/http
/srv/http
└── app

├── app.nginx.conf

@ichpuchtli
ichpuchtli / pacman_pkg_bak.sh
Last active September 9, 2023 17:06
Pacman package dump for backup/restoration of installed pacakges Credit to ProfessorKaos64 of reddit
#!/bin/bash
# pacman_pkg_bak.sh
# reinstall with pacman -S $(cat pkglist)
#Explanation of next steps:
#
#################################
#pacman package backup: #
#################################
#'pacman -Qqet' will (Q)uery (q)uiety and r(e)strict output to #explicitly installed packages (by me #of course, the user, and #further limit that list to what is also unrequired(t).
@ichpuchtli
ichpuchtli / cpm3u.sh
Created September 29, 2013 00:09
cpm3u - Copy each song in a m3u playlist to a directory i.e. cpm3u playlist.m3u /media/ipod
#!/bin/bash
while read line; do
echo $line | grep -v "^#" > /dev/null || continue
size=`stat -c %s "${line}"`
totalsize=$((totalsize + size))
done < $1
echo "Total Size: $(($totalsize / (1024*1024)))M"
@ichpuchtli
ichpuchtli / inet_forward..sh
Created September 28, 2013 10:31
Virtual Ethernet & Internet Sharing for BBB on Arch Linux
#!/usr/bin/bash
# bealebone black virtual ethernet interface
sudo ifconfig usb0 up
sudo ifconfig usb0 192.168.10.1
# internet forwading
sudo iptables -A POSTROUTING -t nat -j MASQUERADE
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
@ichpuchtli
ichpuchtli / atmega48_timer.c
Created April 21, 2013 14:21
atmega48 example code
#define F_CPU 16000000UL
#include <avr/io.h>
#include "util/delay.h"
void init_ADC(void){
// ADC voltage reference
// REFS1 REFS0 Description
// 0 0 AREF