Skip to content

Instantly share code, notes, and snippets.

View micrypt's full-sized avatar

Seyi Ogunyemi micrypt

View GitHub Profile
@micrypt
micrypt / before.scala
Created October 1, 2011 21:08
Squeryl + specs2 examples for a blog post > micrypt.com/2011/07/05/squeryl-specs2-testing-quick-start.html
"allow creation of new entries" >> setupData {
val datum = data.insert(new Datum(0, Some(1),Some(""), Some("ftp.example.org"), Some("username"), Some("password"), Some(new java.util.Date)))
datum.id must_== 1
}
@micrypt
micrypt / cartesian.scala
Created October 1, 2011 13:24
Nifty tricks
val l = Seq(Seq(1,2), Seq(3,4), Seq(5,6))
val l2 = l.map(_.map(Seq(_)))
l2.reduceLeft((xs, ys) => for {x <- xs; y <- ys} yield x ++ y)
@micrypt
micrypt / gist:1207324
Created September 9, 2011 20:59
Fix silly "Networking Disabled" issue (Ubuntu 10.04)
su root
# Don't you hate when you need to root to fix dumb issues?
service network-manager stop
rm /var/lib/NetworkManager/NetworkManager.state
service network-manager start
reboot -h now
@micrypt
micrypt / config.hs
Created August 29, 2011 10:45
XMonad config
atom_WM_TAKE_FOCUS ::
X Atom
atom_WM_TAKE_FOCUS =
getAtom "WM_TAKE_FOCUS"
takeFocusX ::
Window
-> X ()
takeFocusX w =
withWindowSet . const $ do
@micrypt
micrypt / radialBasis.scala
Created August 3, 2011 21:14
Radial Basis Function
import scala.math.{E, pow}
// Vector length
def vecLength(implicit values: List[Double]) = pow(values.sum, .5)
// Radial basis function
def rbf(v1: List[Double], v2: List[Double], gamma:Int = 20) = {
val dv = { for(i <- (0 to v1.length)) yield (v1(i)-v2(i)) }.toList
val l = vecLength(dv)
pow(E, (-gamma*l))
// fb_init.php
require_once('facebook.php');
$facebook = new Facebook(array(
'appId'=>'1234567', // replace with your value
'secret'=>'123abc456def' // replace with your value
));
// reveal.php
include_once('fb_init.php');
@micrypt
micrypt / recommendations.scala
Created July 19, 2011 09:48
Scala translation (Collective Intelligence)
val critics = Map(
"Lisa Rose" -> Map(
"Lady in the Water" -> 2.5,
"Snakes on a Plane" -> 3.5,
"Just My Luck" -> 3.0,
"Superman Returns" -> 3.5,
"You,Me and Dupree" -> 2.5,
"The Night Listener" -> 3.0),
"Gene Seymour" -> Map(
"Lady in the Water" -> 3.0,
@micrypt
micrypt / build.sbt.scala
Created June 28, 2011 11:25
sbt 0.10.0 "meh..." template
name := "My Project"
version := "0.0.1"
scalaVersion := "2.9.0-1"
libraryDependencies ++= Seq(
// Include dependencies
"org.specs2" %% "specs2" % "1.4"
)
@micrypt
micrypt / gist:1048924
Created June 27, 2011 14:10
Riak Quick Start from GitHub
# Install Erlang
$ sudo apt-get install autoconf
$ curl -O https://raw.github.com/dreverri/kerl/master/kerl; chmod a+x kerl
$ ./kerl build R14B03 r14b03
$ ./kerl install r14b03 /opt/erlang/r14b03
$ . ~/.kerl/installs/r14b03/activate
# Build Riak from source
$ git clone git://github.com/basho/riak.git
$ cd riak
@micrypt
micrypt / gist:1035659
Created June 20, 2011 14:09
*nix Annoyances
#! /bin/sh
# dumb ass Xfce
xrandr --auto --output VGA1 --mode 1920x1080 --right-of LVDS1
Broadcom wireless troubles:
I had success getting this to work by marking these five packages for reinstallation in the synaptic package manager:
bcmwl-kernel-source