2015-10-21
- jennifer
- martym
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env | |
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced | |
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start | |
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running. | |
# Add the following to your shell init to set up gpg-agent automatically for every shell | |
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then | |
source ~/.gnupg/.gpg-agent-info | |
export GPG_AGENT_INFO | |
else |
F#
.net 4.5 - immutable collections, nuget package - developed by microsoft. core library source available - including roslin, compiler as a service.
#!/usr/bin/ruby | |
# Create display override file to force Mac OS X to use RGB mode for Display | |
# see http://embdev.net/topic/284710 | |
require 'base64' | |
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay` | |
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten | |
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten |
case class Person(name: String, age: Int) | |
implicit val DecodePerson: DecodeJson[Person] = jdecode2L(Person(_: String, _: Int))("name", "age") | |
implicit val EncodePerson: EncodeJson[Person] = jencode2L((p: Person) => (p.name, p.age))("name", "age") | |
val decoded: Option[Person] = """{"name":"Fred","age":"40"}""".decodeOption[Person] | |
val encoded: Option[String] = decoded.map(_.jencode.nospaces) |
object T { | |
implicit def XIntToInt(x: XInt): Int = x.n | |
// isomorphism to Int | |
case class XInt(n: Int) | |
case class Wibble[A](a: A) { | |
def wibble(implicit ev: A <:< Int) = a + 9 | |
def map[B](f: A => B) = |
val username: Option[String] \/ String = for { | |
parsed <- requestJson.parse.swapped(_.map(_.some)) // Parse the JSON. | |
jsonObject <- parsed.obj.toRight[Option[String]] // Get the JSON as a JsonObject instance. | |
userIDJson <- jsonObject("userid").toRight[Option[String]] // Get the "userid" field from the JsonObject. | |
userID <- userIDJson.string.toRight[Option[String]] // Get the value of the "userid" field. | |
user <- lookupUser(userID).toRight[Option[String]] // Get an instance of User for the user ID. | |
} yield user.username |
import Data.Monoid | |
import Control.Monad.State | |
import Control.Monad.Reader | |
data RequestHeaders = | |
RequestHeaders [(String, String)] | |
data ResponseHeaders = | |
ResponseHeaders [(String, String)] |
import Data.Text | |
import Control.Monad.Reader | |
data ZResult a = | |
ZVal a | |
| ZNotFound | |
| ZFail Text | |
| ZUnauth Text | |
newtype ZResultT m a = ZResultT { |