Skip to content

Instantly share code, notes, and snippets.

// Welcome to Scala version 2.7.5.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_20).
// Type in expressions to have them evaluated.
// Type :help for more information.
scala> import dispatch._
import dispatch._
scala> import oauth._
import oauth._
@steveswing
steveswing / PasswordField
Created April 27, 2011 15:45 — forked from eltimn/PasswordField
Lift-Record Password Field
import java.util.regex._
import scala.xml._
import org.mindrot.jbcrypt.BCrypt
import net.liftweb._
import common._
import http.S
import http.js._
import json.JsonAST.{JNothing, JNull, JString, JValue}
@steveswing
steveswing / PasswordFieldSpecs.scala
Created April 27, 2011 16:18 — forked from anonymous/PasswordFieldSpecs.scala
Unit Test for reporting a bug with PasswordField
package code
import org.specs._
import _root_.net.liftweb.mongodb.record._
import _root_.net.liftweb.record.field._
class SampleRecord extends MongoRecord[SampleRecord]
with MongoId[SampleRecord] {
def meta = SampleRecord
# Apple Binary Property List serializer for Ruby 1.8.
require 'iconv'
module AppleBinaryPropertyList
MIME_TYPE = 'application/octet-stream' # Don't know what to use, so use a very generic type for now
CFData = Struct.new(:data) # For marking strings as binary data which will be decoded as a CFData object
@steveswing
steveswing / org.mongodb.mongod.plist
Created July 16, 2012 22:38 — forked from bwmcadams/org.mongodb.mongod.plist
Suggested Plist for Mac MongoDB 1.8+, enables durability and clean shutdown
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.mongodb.mongod</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mongodb/bin/mongod</string>
<string>run</string>
@steveswing
steveswing / os-x-enable-trim.txt
Created October 13, 2012 15:28 — forked from clarencesong/os-x-enable-trim.md
Enable TRIM in OS X 10.8.2
Enable TRIM on non-Apple SSDs in OS X 10.8.2 Mountain Lion.
WARNING: This is ONLY tested on 10.8.2, and NOT earlier or later versions. YMMV.
Technical note: The driver changed in 10.8.2 and similar perl commands that worked in earlier OS X versions did not work for me once I updated to 10.8.2.
Run the following commands in Terminal…
1. Backup the original driver. Added -p to preserve original metadata about the file
sudo cp -p /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage ~root/IOAHCIBlockStorage-original
Enable TRIM on non-Apple SSDs in OS X 10.8.2 Mountain Lion.
WARNING: This is ONLY tested on 10.8.2 (IOAHCIBlockStorage version 2.3.1), and NOT earlier or later versions.
Check /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/version.plist
Technical note: The driver changed in 10.8.2 and similar perl commands that worked in earlier OS X versions did not work for me once I updated to 10.8.2.
Run the following commands in Terminal…
@steveswing
steveswing / InstallCert.java
Created May 20, 2013 16:06
A useful tool to import certificates into a copy of cacerts.
/*
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original
# for Mountain Lion 10.8.3 - 10.8.5
sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mountain Lion 10.8.1-10.8.2 and Lion 10.7.5
#sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x4D)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
# for Mountain Lion 10.8.0 and Lion 10.7.4 BELOW
#sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x51)|
import java.io.File
/**
* A completely OS-Agnostic way of dealing with java.io.File paths
*/
object RichPath {
sealed class RichBase[+A](left: A) {
/**
* Simple enrichment method designed to let you create a java.io.File
* by simply writing "folderA" / "folderB" / "folderC"