gen_server:start(ModuleName, Arguments, Options) -> {ok, Pid} | {error, Reason}
gen_server:start(ServerName, ModuleName, Arguments, Options) -> {ok, Pid} | {error, Reason}
import bisect | |
import itertools | |
import operator | |
class _BNode(object): | |
__slots__ = ["tree", "contents", "children"] | |
def __init__(self, tree, contents=None, children=None): | |
self.tree = tree |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; Copyright (c) Rich Hickey. All rights reserved. | |
; The use and distribution terms for this software are covered by the | |
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php) | |
; which can be found in the file CPL.TXT at the root of this distribution. | |
; By using this software in any fashion, you are agreeing to be bound by | |
; the terms of this license. | |
; You must not remove this notice, or any other, from this software. | |
;dimensions of square world |
(ns fsm | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic])) | |
;; Encoding a Finite State Machine and recognizing strings in its language in Clojure core.logic | |
;; We will encode the following FSM: | |
;; | |
;; (ok) --+---b---> (fail) | |
;; ^ | |
(ns myapp.authenticate.oauth | |
"OAuth authentication" | |
(:require | |
[cheshire.core :as json] | |
[clj-http.client :as http] | |
[clojure.string :as string] | |
[clojure.tools.logging :as logging]) | |
(:use | |
[oauthentic.core :only [build-authorization-url fetch-token]] | |
[ring.util.response :only [redirect]] |
## Set up SmartOS in VirtualBox | |
# http://www.perkin.org.uk/posts/automated-virtualbox-smartos-installs.html | |
# set up global zone with Joyent datasets | |
if [[ ! -e /var/db/imgadm/sources.list || `grep -v "https://datasets.joyent.com/datasets" /var/db/imgadm/sources.list` ]]; then | |
echo "https://datasets.joyent.com/datasets" >> /var/db/imgadm/sources.list | |
fi | |
imgadm update |
EDIT! full code can be found here gist
So I played around with rust a bit now. And I thought I might share some random stuff.
So say you wanted to represent a expression tree with plus and minus nodes and a node for values. One way to do this would be to use rust's enum's.
In rust enums are like haskell's union types so you can specify the different values to be constructors carrying data.
x = 10000.times.to_a | |
a,b,c = x.dup, x.dup, x.dup | |
Benchmark.measure { 1000.times { out = []; out += a; out += b; out +=c; out.uniq! } } | |
Benchmark.measure { 1000.times { out = Set.new; out += a; out += b; out +=c; } } | |
Benchmark.measure { 1000.times { out = {}; a.each {|e| out[e] ||= 1}; b.each {|e| out[e] ||= 1}; c.each {|e| out[e] ||= 1}; } } |
<script language="JavaScript" type="text/javascript"> | |
// Comcast Cable Communications, LLC Proprietary. Copyright 2012. | |
// Intended use is to display browser notifications for critical and time sensitive alerts. | |
var SYS_URL='/e8f6b078-0f35-11de-85c5-efc5ef23aa1f/aupm/notify.do'; | |
// var image_url='http://servicealerts.comcast.net:8080/images/mt'; | |
var image_url='http://xfinity.comcast.net/constantguard/BotAssistance/notice/images'; | |
var headertext1='<strong>Comcast Courtesy Notice</strong>'; | |
var textline1='You have reached 90% of your <b>monthly data usage allowance</b>.'; | |
var textline2='Please sign in for more information and to remove this alert.'; | |
var acknowledgebutton='<a href=\"#\" onClick="document.location.href=\''+SYS_URL+'?dispatch=redirect&redirectName=login¶mName=bmUid\'" title="Sign in to acknowledge" style="color: #FFFFFF;"><img alt="Sign in to acknowledge" src="'+image_url+'/mt_signin.png"/></a>'; |