Skip to content

Instantly share code, notes, and snippets.

// HOWTO: load LABjs itself dynamically!
// inline this code in your page to load LABjs itself dynamically, if you're so inclined.
(function (global, oDOC, handler) {
var head = oDOC.head || oDOC.getElementsByTagName("head");
function LABjsLoaded() {
// do cool stuff with $LAB here
}
@amscotti
amscotti / md5.coffee
Last active January 18, 2021 12:54
MD5 hashing
crypto = require('crypto');
#Quick MD5 of text
text = "MD5 this text!"
md5hash1 = crypto.createHash('md5').update(text).digest("hex")
#MD5 of text with updates
m = crypto.createHash('md5')
m.update("MD5 ")
m.update("this ")
@(field:Field, min:Int=1)(f: (Field, Int) => Html)
@{
(0 until math.max(if (field.indexes.isEmpty) 0 else field.indexes.max + 1, min)).map(i => f(field("[" + i + "]"),i))
}
@ramn
ramn / Deserialization.scala
Last active October 18, 2023 17:42
Object serialization example in Scala
import java.io._
@SerialVersionUID(15L)
class Animal(name: String, age: Int) extends Serializable {
override def toString = s"Animal($name, $age)"
}
case class Person(name: String)
// or fork := true in sbt
@mguillermin
mguillermin / generated_jsRoutes.js
Last active May 24, 2016 21:57
Submitting Ajax POST with PlayFramework 2.x and the Javascript Router
...
_nS('controllers.admin.Products'); _root.controllers.admin.Products.search =
function() {
return _wA({method:"POST", url:"/" + "admin/product/search"})
}
...
@ktheory
ktheory / dd.log
Last active November 10, 2023 23:41
EC2 EBS-SSD vs instance-store performance on an EBS-optimized m3.2xlarge
# /tmp/test = EBS-SSD
# /mnt/test = instance-store
root@ip-10-0-2-6:~# dd bs=1M count=256 if=/dev/zero of=/tmp/test
256+0 records in
256+0 records out
268435456 bytes (268 MB) copied, 3.26957 s, 82.1 MB/s
root@ip-10-0-2-6:~# dd bs=1M count=256 if=/dev/zero of=/tmp/test
256+0 records in
256+0 records out
@iansltx
iansltx / _safari-iframe-cookie-workaround.md
Last active May 1, 2023 21:56
Safari iframe cookie workaround
@tanitanin
tanitanin / optionBinder.scala
Last active July 27, 2018 18:58
QueryStringBindable and Formatter for Option[T] ( @ Play Framework 2.x )
import play.api.data._
import play.api.data.format._
import play.api.data.format.Formats._
/**
* Option[T]をクエリとして解決するためのバインダ(必須でないパラメータなどに利用することを想定)
* 通常のFormと同様にbindFromRequestして使う
* クエリに該当するキーが含まれていない場合にはFormの値がNoneになる
*
* こんなかんじ (もっときれいに書きたいけど):
@chrismdp
chrismdp / s3.sh
Last active March 5, 2024 12:57
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@jorihardman
jorihardman / sumo_logic.config
Last active April 27, 2023 18:43
Elastic Beanstalk Sumo Logic Config
# This will automatically install the Sumo Logic collector on AWS Elastic
# Beanstalk instances. Add this to the .ebextensions folder in your app root
# and edit L24-25 to match your Sumo Logic accessid and accesskey. To add or
# remove tracked files, simply add or remove source hashes to the sources
# array on L36.
packages:
rpm:
SumoCollector: https://collectors.sumologic.com/rest/download/rpm/64
services: