Skip to content

Instantly share code, notes, and snippets.

View shapr's full-sized avatar
🏃
VENTRE À TERRE

Shae Erisson shapr

🏃
VENTRE À TERRE
View GitHub Profile
@shapr
shapr / blog.hs
Created April 15, 2012 21:27
yesod book blog example
{-# LANGUAGE OverloadedStrings, TypeFamilies, QuasiQuotes, TemplateHaskell, GADTs, FlexibleContexts, MultiParamTypeClasses #-}
import Yesod
import Yesod.Auth
import Yesod.Form.Nic (YesodNic, nicHtmlField)
import Yesod.Auth.BrowserId (authBrowserId)
import Data.Text (Text)
import Network.HTTP.Conduit (Manager, newManager, def)
import Database.Persist.Sqlite (ConnectionPool, SqlPersist, runSqlPool, runMigration, createSqlitePool )
import Data.Time (UTCTime, getCurrentTime)
@shapr
shapr / Blog.hs
Created April 15, 2012 21:52
yesod book example blog, typos fixed
{-# LANGUAGE OverloadedStrings, TypeFamilies, QuasiQuotes, TemplateHaskell, GADTs, FlexibleContexts, MultiParamTypeClasses #-}
import Yesod
import Yesod.Auth
import Yesod.Form.Nic (YesodNic, nicHtmlField)
import Yesod.Auth.BrowserId (authBrowserId)
import Data.Text (Text)
import Network.HTTP.Conduit (Manager, newManager, def)
import Database.Persist.Sqlite (ConnectionPool, SqlPersist, runSqlPool, runMigration, createSqlitePool )
import Data.Time (UTCTime, getCurrentTime)
*Smerdyakov* Maybe you are viewing the channel in a fundamentally different way than I am.
*Smerdyakov* I do _not_ view it as the clubhouse of a particular community working to create software.
*Smerdyakov* I view it as a general channel for people who happen to share an interest in Haskell.
*Smerdyakov* I think the second interpretation is the established standard for programming language IRC channels.
*Smerdyakov* And in that interpretation, there is no obligation/compunction to say things that promote production of software.
<shapr> I believe there is an obligation to say things that promote a community.
*Smerdyakov* And I don't.
@shapr
shapr / gsms.py
Created May 21, 2013 23:13
Part of the code I use to check gvoice SMS messages on my laptop and Raspberry Pi
import sqlite3 as lite
import imaplib
import email
# assume gtk is all good
import gnotify
# assume db has been setup correctly
def createtyrnidb():
@shapr
shapr / delay-prompt
Created June 7, 2013 13:38
Arduino sketch to ask for how many seconds to delay, for my spouse-safe wrist alarm, first working version, don't expect beauty
int powerPin = 17;
int groundPin = 19;
int failcount = 0;
char buffer[18];
void setup() {
Serial.begin(9600);
Serial.flush();
pinMode(powerPin,OUTPUT);
pinMode(groundPin,OUTPUT);
@shapr
shapr / hourscalc.py
Created June 24, 2013 03:17
time now to time alarm, in minutes, less than 24 hours from now
"""
The Arduino alarm clock asks you for the current time and the time to awake, and then waits that many minutes.
"""
# mmm, python
def hourscalc(hoursnow,minutesnow,hoursalarm,minutesalarm):
"""input is (hoursnow,minutesnow) and (hoursalarm,minutesalarm)
and should look like hourscalc((00,30),(07,30))"""
# NOW AND ALARM ARE IN MINUTES dude!
@shapr
shapr / beaglecharlie.py
Last active December 23, 2015 02:29
first hack at charlieplexing with Adafruit_BBIO
import Adafruit_BBIO.GPIO as GPIO
import time
pins = ["P8_12","P8_14","P8_16","P8_18","P8_20","P8_22"]
for p in pins:
GPIO.setup(p, GPIO.OUT)
def setnums(n):
listvals = []
bitstring = bin(n)[2:]
for x in bitstring:
@shapr
shapr / dbexport.py
Created May 27, 2014 16:27
Jython: use Jackcess to csv export all the tables from whatever Jackcess supports, including Access 97, 2000, 2003, 2007, 2010
# required apt-get install jython libcommons-logging-java libcommons-lang-java
import sys
sys.path.append('jackcess-2.0.4.jar') # assume the jackcess is in the same directory
sys.path.append('/usr/share/java/commons-logging-1.1.3.jar') # in case logging didn't get picked up
sys.path.append('/usr/share/java/commons-lang-2.6.jar') # in case lang didn't get picked up
from com.healthmarketscience.jackcess import *
from com.healthmarketscience.jackcess.util import ExportFilter
from com.healthmarketscience.jackcess.util import ExportUtil
from com.healthmarketscience.jackcess.util import SimpleExportFilter
import java.io
@shapr
shapr / uniquifiers benchmark results
Last active August 29, 2015 14:05
uniquifiers benchmark results
from http://www.peterbe.com/plog/uniqifiers-benchmark:
6-core AMD @3.5GHz desktop with 16gb of RAM
ᐅ python uniqifiers_benchmark.py
* f5 2.453
* f5b 2.43
* f8 1.38
* f10 1.504
* f11 1.523
f1 1.088
@shapr
shapr / shae-lojban.el
Created April 15, 2015 19:55
shae's lojban defuns
;;;;;;;;; lojban defuns
(defun lojban-gloss () ""
(interactive "r")
(shell-command-on-region (region-beginning) (region-end)
"cmafihe -b"))
(defun lojban-parse () ""
(interactive)
(shell-command-on-region (region-beginning) (region-end)
"jbofihe -x -b"))