Skip to content

Instantly share code, notes, and snippets.

@annappropriate
annappropriate / UpdateReturning.scala
Created June 10, 2016 08:54
Update returning for Slick 3.1.1
private def updateReturning[A, F](
returningQuery: Query[A, F, C], v: U): SqlStreamingAction[Vector[F], F, Effect.All] = {
val ResultSetMapping(
_, CompiledStatement(_, sres: SQLBuilder.Result, _), CompiledMapping(_updateConverter, _)) =
updateCompiler.run(updateQuery.toNode).tree
val pconv: SetParameter[U] = {
val ResultSetMapping(_, compiled, CompiledMapping(_converter, _)) =
updateCompiler.run(updateQuery.toNode).tree
val converter = _converter.asInstanceOf[ResultConverter[JdbcResultConverterDomain, U]]
@annappropriate
annappropriate / snake.ino
Created April 3, 2015 10:04
LED matrix + Joystick snake game
#include <LedControl.h>
// Display
int din = 8;
int clk = 10;
int cs = 9;
// Joystick click
int sw = 5;
#include <dht.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
DHT dht11 = DHT();
int HIH4030_Pin = A5;
void setup() {
lcd.init();
@annappropriate
annappropriate / gist:d0f523e2fa57f0daabb7
Created March 15, 2015 17:26
How to install bootable Windows on USB stick
1. Format USB stick to FAT32: mkfs.fat -F 32 /dev/sdb1
2. Use http://unetbootin.sourceforge.net/ to write Windows ISO to the USB drive
3. Copy chain32 to the flash drive's root directory: cp /usr/share/syslinux/chain.c32 /media/my_flash_drive
4. Paste the following into syslinux.cfg (located at drive's root):
default windows
prompt 0
menu title UNetbootin
timeout 0
LABEL windows
@annappropriate
annappropriate / service_poker_def_proto.rb
Last active December 14, 2015 20:49
Prototype of Chef service poking script
# url => link to poke
# name => human-readable name
# anchor => phrase to look for at page
define :poke_service do
def is_loaded?
Timeout::timeout(3) {
open params[:url].read.include? params[:anchor]
}
rescue WhateverExceptionsThereHappen
puts "#{params[:name]} is loading..."; sleep 10 and reload
My (not yet complete) solutions to exercises from 'Programming in Scala' book