This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.xml._ | |
import java.net.{URLConnection, URL} | |
class RSSRead { | |
def getFeed(feedUrl: String) = { | |
val url = new URL(feedUrl) | |
val connect = url.openConnection | |
val feed = XML.load(connect.getInputStream) | |
feed \\ "channel" \\ "item" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Basic OCaml Tokyo Tyrant Client. | |
* Currently, only supports get and put, but may eventually add all | |
* the exciting other features. | |
* | |
* -Cooper Francis. | |
*) | |
#use "topfind";; | |
#camlp4o;; | |
#require "lwt";; | |
#require "unix";; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn listify [orig-list] | |
"Turns (1 2 3 ...) into (1 (2 (3 (...)))) using continuation passing style." | |
(loop [lst orig-list cont identity] | |
(if (= () lst) | |
(cont ()) | |
(recur (rest lst) | |
(fn [insert] | |
(cont (cons (first lst) | |
(list insert)))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.ArrayIndexOutOfBoundsException: 42 | |
at scala.tools.nsc.ast.TreeGen.scalaFunctionConstr(TreeGen.scala:36) | |
at scala.tools.nsc.typechecker.Unapplies$class.createFun$1(Unapplies.scala:138) | |
at scala.tools.nsc.typechecker.Unapplies$class.parents$1(Unapplies.scala:139) | |
at scala.tools.nsc.typechecker.Unapplies$class.caseModuleDef(Unapplies.scala:141) | |
at scala.tools.nsc.Global$analyzer$.caseModuleDef(Global.scala:291) | |
at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$5.apply(Namers.scala:354) | |
at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$5.apply(Namers.scala:354) | |
at scala.tools.nsc.typechecker.Namers$Namer.ensureCompanionObject(Namers.scala:296) | |
at scala.tools.nsc.typechecker.Namers$Namer.enterSym(Namers.scala:354) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("gtools") | |
require("hash") | |
# Thunks an expression. Basic lazy evaluation. | |
thunk <- defmacro(x, expr=function() x) | |
# But it turns out this is unnecessary! R lazily evaluates its arguments! | |
thunk2 <- function(x) { function() { x } } | |
# Further: | |
delayedAssign("x", 1/0) | |
# actually is better than what I'd implemented so far: creates a promise for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.NullPointerException | |
at scala.Array$$anon$2.apply(Array.scala:46) | |
at scala.Array$$anon$2.apply(Array.scala:45) | |
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:226) | |
at scala.collection.mutable.ArrayOps.flatMap(ArrayOps.scala:34) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> lst | |
[,1] [,2] [,3] | |
[1,] "3" "2" "1" | |
> table(lst, lst) | |
Error in sort.list(y) : | |
'x' must be atomic for 'sort.list' | |
Have you called 'sort' on a list? | |
> traceback() | |
4: stop("'x' must be atomic for 'sort.list'\nHave you called 'sort' on a list?") | |
3: sort.list(y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From the repl: | |
scala> val features: Seq[Array[FeatureNode]] = values._2 | |
features: Seq[Array[liblinear.FeatureNode]] = List(Array(FeatureNode(idx=1, value=1.0)), Array(FeatureNode(idx=2, value=1.0))) | |
scala> features.toArray | |
res5: Array[Array[liblinear.FeatureNode]] = Array(Array(FeatureNode(idx=1, value=1.0)), Array(FeatureNode(idx=2, value=1.0))) | |
// But when this is otherwise executed: | |
[info] null (TraversableOnce.scala:388) | |
[info] scala.collection.TraversableOnce$class.toArray(TraversableOnce.scala:388) | |
[info] scala.collection.immutable.List.toArray(List.scala:45) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim StripeURL, APIKey | |
StripeURL = "https://api.stripe.com/v1/charges" | |
APIKey = <YOUR SECRET KEY> | |
Function makeStripeAPICall(requestBody) | |
Dim objXmlHttpMain | |
Set objXmlHttpMain = CreateObject("Msxml2.ServerXMLHTTP") | |
On Error Resume Next | |
objXmlHttpMain.open "POST", StripeURL, False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| znc response | | |
ZnNetworkingUtils defaultSocketStreamTimeout: 60. | |
(znc := ZnClient new) logToTranscript. | |
response := znc | |
url: 'https://api.stripe.com/v1/charges'; | |
headerAt: 'Authorization' | |
add: ('BEARER {1}' format: { <YOUR KEY> }); | |
formAt: 'amount' put: '1000'; |
OlderNewer