Skip to content

Instantly share code, notes, and snippets.

process.on('uncaughtException', function (err) {
console.log('exception: ' + err);
console.log('stack: ' + err.stack);
});
require('Task/Joose/NodeJS');
use(['KiokuJS.Backend.CouchDB', 'KiokuJS.Linker'], function () {
var handle = new KiokuJS.Backend.CouchDB({
dbURL : 'http://localhost:5984/test'
});
var scope = handle.newScope();
var Options = Cactus.Util.Options;
var jade = require("jade");
var C = Cactus.Data.Collection;
Class("CpsJade", {
has : {
layoutFile : { required : true }
},
trait : JooseX.CPS,
methods : {
_parseArgs : function (args) {
@bergmark
bergmark / browser-navigator.json
Created April 27, 2011 05:13
Browser navigator objects in JSON format
{
"chrome 10.0 osx" : {
"language" : "en-US",
"product" : "Gecko"
},
"chrome 10.0 win" : {
"language" : "sv",
"product" : "Gecko"
},
"ie 8.0 win" : {
var editUser = new FormHelper({
action : "/edit",
fields : {
name : {
in : { type : "string" },
out : {
// Will always be string or ["string"] for form submissions.
type : "string",
validators : [{
required : true,
TRY(function () {
try {
this.CONT.CONTINUE();
} catch (e) {
console.log("catch 1");
}
}).THEN(function () {
throw 1;
}).NOW();
prepareDto : function (vals, helpers) {
var dto = this.newDto();
dto.reversePopulate(vals, helpers).then(function () {
try {
var fields = dto.get(helpers);
} catch (e) {
setTimeout(this.getTHROW().curry(e), 0);
return;
}
setTimeout(this.getCONTINUE().curry(fields), 0);
cpanm (App::cpanminus) 1.4008 on perl 5.010001 built for x86_64-linux-gnu-thread-multi
Work directory is /home/adam/.cpanm/work/1314969734.22227
You have make /usr/bin/make
You have LWP 5.836
You have /bin/tar: tar (GNU tar) 1.23
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
@bergmark
bergmark / gist:1625460
Created January 17, 2012 07:34
fallout hack solver
#!/usr/bin/env ruby
pairs = []
while !(print '> ') && (s = gets.strip) != ''
word,num = /^(\S+)\s*(\d+)?$/.match(s)[1..2]
if num
pairs << [word,num.to_i]
else
print(pairs.map { |p_word,p_num|
p_num == word.chars.zip(p_word.chars).inject(0) { |s,(a,b)| s + (a == b ? 1 : 0) }
}.all? ? "match\n" : "no match\n")
Prelude Text.Regex.Posix> "bar" =~ "(foo|bar)" :: Bool
<interactive>:1:7:
No instances for (RegexMaker Regex CompOption ExecOption [Char],
RegexContext Regex [Char] Bool)
arising from a use of `=~'
Possible fix:
add instance declarations for
(RegexMaker Regex CompOption ExecOption [Char],
RegexContext Regex [Char] Bool)
Haskell:
data Select = FirstAlternative String String
| SecondAlternative Select Select
| ThirdAlternative Select
printSelect :: Select -> IO ()
printSelect (FirstAlternative str1 str2) =
putStr("FirstAlternative(" ++ str1 ++ ", " ++ str2 ++ ")")
printSelect (SecondAlternative sel1 sel2) = do