Skip to content

Instantly share code, notes, and snippets.

@davegurnell
davegurnell / anorm.scala
Last active June 5, 2024 14:26
A short guide to Anorm
/*
Overview
--------
To run a query using anorm you need to do three things:
1. Connect to the database (with or without a transaction)
2. Create an instance of `anorm.SqlQuery` using the `SQL` string interpolator
3. Call one of the methods on `SqlQuery` to actually run the query
@felixrabe
felixrabe / string-utils.coffee
Last active September 29, 2023 16:39
CoffeeScript: String.startsWith() and String.endsWith()
# http://stackoverflow.com/a/646643
String::startsWith ?= (s) -> @slice(0, s.length) == s
String::endsWith ?= (s) -> s == '' or @slice(-s.length) == s
@sergeych
sergeych / NameCode32.java
Last active December 27, 2015 08:09
Effectively encodes/decodes binary data to the text suitable to use as urls and file names, unlike Base64 which is case-sensitive
package net.sergeych.utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* Binary to text encoder suitable to use encoded strings as any parts of urls
* and parts of file names safely even on case-insensitive systems. Human
* friendly, easy to retype from print or from voice, treats confusing
@howlingblast
howlingblast / gist:5814547
Created June 19, 2013 14:00
CoffeeScript: getter/setter example
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
class Person
constructor: (@firstName, @lastName) ->
@property 'fullName',
get: -> "#{@firstName} #{@lastName}"
set: (name) -> [@firstName, @lastName] = name.split ' '
p = new Person 'Leroy', 'Jenkins'