This widget creates a growl-like notification on a website using CanJS framework.
JavaScript
steal('can/construct',
'can/construct/super',
'can/construct/proxy',
'can/control',
-lpthread -lcrypt -lm /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.9/ext/nginx/../common/libpassenger_common.a /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.9/ext/nginx/../common/libboost_oxt.a -lstdc++ -lpthread /tmp/root-passenger-8277/pcre-8.12/.libs/libpcre.a -lssl -lcrypto -ldl -lz | |
/usr/bin/ld: /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.9/ext/nginx/../common/libpassenger_common.a(aggregate.o): undefined reference to symbol 'round@@GLIBC_2.2.5' | |
/usr/bin/ld: note: 'round@@GLIBC_2.2.5' is defined in DSO /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libm.so so try adding it to the linker command line | |
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libm.so: could not read symbols: Invalid operation | |
collect2: ld returned 1 exit status | |
make[1]: *** [objs/nginx] Error 1 | |
make[1]: Leaving directory `/home/schovi/tmp/nginx' | |
make: *** [build] Error 2 | |
-------------------------------------------- |
processDbRequest :: Connection -> [String] -> String | |
processDbRequest conn record@(tableId:requestType:_:rawParams) = | |
let params = extractParams rawParams | |
tableId = read tableId | |
recordId = read (params M.! 1) | |
in case tableId of | |
1 -> "yes" | |
_ -> "oh no" |
schovi@Connie~/tmp/haskell$ ghci | |
GHCi, version 7.4.2: http://www.haskell.org/ghc/ :? for help | |
Loading package ghc-prim ... linking ... done. | |
Loading package integer-gmp ... linking ... done. | |
Loading package base ... linking ... done. | |
Prelude> :l time | |
[1 of 1] Compiling Main ( time.hs, interpreted ) | |
Ok, modules loaded: Main. | |
*Main> date | |
Loading package array-0.4.0.0 ... linking ... done. |
data Record = Record { subject :: Subject | |
, logo :: Maybe Logo | |
, address :: Maybe Address | |
, branchRecords :: [BranchRecord] | |
, subscriptions :: [Subscription] | |
, comments :: [Comment] | |
, categories :: [String] | |
, keywords :: [String] | |
} deriving (Show, Eq) |
$ curl -XPUT 'http://localhost:9200/twitter/' -d '{ | |
index : { | |
number_of_shards : 3 | |
number_of_replicas : 2 | |
} | |
}' |
can.EJS.Helpers.prototype.plugin = function(plugin, params) { | |
return function(el) { | |
if(typeof plugin == "string") { | |
$(el)[plugin](params); | |
} else { | |
new plugin(el, params) | |
} | |
} | |
} |
<div <%= (el) -> can.data(el,'article',this) %> class="hidden article article-<%= this.id %>" <%= (el) -> el.fadeIn()%> > | |
<%= this.name %> | |
</div> |
// jsFiddle example | |
// http://jsfiddle.net/k7Fgt/1/ | |
stringifiedObject = { | |
"index.analysis.analyzer.standard_lower_ascii.type" : "custom", | |
"index.refresh_interval" : "60s", | |
"index.analysis.analyzer.standard_lower_ascii.filter.0" : "standard", | |
"index.analysis.analyzer.remove_whitespaces.filter.1" : "remove_whitespaces", | |
"index.analysis.filter.remove_whitespaces.type" : "pattern_replace", | |
"index.number_of_shards" : "4", |
// All calls reponses are converted into model instances or attributes are applied to current instance | |
var Api = can.Model('Api', { | |
callEndpoint: function(url) { | |
var ajax = this._ajax({}, url).call(this), | |
def = new can.Deferred(), | |
promise = def.promise(), | |
self = this; | |
promise.abort = ajax.abort |