Skip to content

Instantly share code, notes, and snippets.

View conikeec's full-sized avatar

Chetan Conikee conikeec

View GitHub Profile
import com.mongodb.casbah.Imports._
/*
* Simple test of the MongoDB Aggregation Framework via Casbah
*
* [Note: only works on MongoDB 2.1+]
*
* The "students" collection consists of student test score records that [simplified] look like this:
*
{

Debugging Go on OS X

Step 1: Get GDB.

Some of the fancy features Go adds to GDB require GDB >= 7.1. You can check which version you have with gdb -v. If it's high enough, skip to the next section. If not, do the following:

  1. Follow these instructions: http://www.opensource.apple.com/source/lldb/lldb-69/docs/code-signing.txt. The name doesn't matter really, but gdb_codesign is as good a choice as any.

  2. brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb.

import com.mongodb.casbah.Imports._
/*
* Simple test of the MongoDB Aggregation Framework via Casbah
*
* [Note: only works on MongoDB 2.1+]
*
* The "students" collection consists of student test score records that [simplified] look like this:
*
{
@conikeec
conikeec / e1071.R
Created March 19, 2013 03:53 — forked from ivannp/e1071.R
svmComputeOneForecast = function(
id,
data,
response,
startPoints,
endPoints,
len,
history=500,
trace=FALSE,
kernel="radial",
// Read lines from a bunch of files given on the command line
// and write them out in sorted order, like Unix sort(1).
//
// Written by Lars Buitinck, 2012.
// This code is in the public domain.
package main
import (
"bufio"
package main
import (
"code.google.com/p/go.net/websocket"
"flag"
"log"
"net/http"
"os"
)
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@conikeec
conikeec / md5.coffee
Created November 28, 2012 00:35 — forked from amscotti/md5.coffee
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 ")
@conikeec
conikeec / Secured.scala
Created November 6, 2012 01:19 — forked from guillaumebort/Secured.scala
HTTP Basic Authorization for Play 2.0
def Secured[A](username: String, password: String)(action: Action[A]) = Action(action.parser) { request =>
request.headers.get("Authorization").flatMap { authorization =>
authorization.split(" ").drop(1).headOption.filter { encoded =>
new String(org.apache.commons.codec.binary.Base64.decodeBase64(encoded.getBytes)).split(":").toList match {
case u :: p :: Nil if u == username && password == p => true
case _ => false
}
}.map(_ => action(request))
}.getOrElse {
Unauthorized.withHeaders("WWW-Authenticate" -> """Basic realm="Secured"""")
@conikeec
conikeec / exactchange.go
Created October 24, 2012 23:39 — forked from bilange/exactchange.go
Exact change calculation
/*
* Exact change calculator (recursion learning exercice)
* Eric Belanger // github.com/bilange // Twitter: @bilange
*
* This code has been build to demonstrate how to do recursion, for people who
* wants to know Go better via code examples. This code has been HIGHLY
* documented to help the learning process. Feel free to fork, base upon or
* otherwise copy this code! :-)
*
* This MAY be NOT the only way to do this task, so feel free to experiment!