This file contains hidden or 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
| ; Roboto-FFI! | |
| (= LibM | |
| (ffi-bind '("m") '("math.h") | |
| (pi (ffi-const 'double 'M_PI)) | |
| (sin (ffi-func 'double 'sin '(double))))) | |
| (LibM '(do | |
| (= epsilon 0.000001) | |
| (def within-epsilon (a b) | |
| (< (- epsilon) (- a b) epsilon)))) |
This file contains hidden or 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
| # Ruby's awesome constant-resolution rules. | |
| module X | |
| A = 5 | |
| end | |
| module X | |
| class Y | |
| def z | |
| A |
This file contains hidden or 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
| h = {} | |
| ary.each { |i| | |
| if h[[i.foo, i.bar]] | |
| i.is_a_dup! | |
| else | |
| h[[i.foo, i.bar]] = true | |
| end | |
| } |
This file contains hidden or 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
| # I have successfully defeated Ruby-FFI to produce a pointer to an | |
| # arbitrary memory location: | |
| module C | |
| extend FFI::Library | |
| extend self | |
| attach_function :atoi, [:string], :pointer | |
| def pointer_to address |
This file contains hidden or 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
| ; This is how you simulate dynamic scoping in Clojure (as far as I can | |
| ; tell): | |
| (defn print-foo [] (println foo)) ; -> #'user/print-foo | |
| ; Now, try calling print-foo from both a let and a binding: | |
| (let [foo "let foo"] (print-foo)) | |
| ; 10 | |
| (binding [foo "bound foo"] (print-foo)) | |
| ; bound foo | |
| ; In Roboto, if you wanted to do this but didn't want to use a macro, |
This file contains hidden or 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
| ; A demonstration of OO in Roboto | |
| ; Class definition: | |
| (= Timer (Class 'new | |
| (bind () | |
| (def new upto | |
| (bind ((upto upto) (ticks 0)))) | |
| (def tick () | |
| (+= ticks 1) | |
| (%= ticks upto))))) | |
| ; Instantiation |
This file contains hidden or 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
| int atoi(char *str) | |
| { | |
| int acc = 0; | |
| while(*str) { | |
| if(*str >= '0' && *str <= '9') | |
| acc = acc * 10 + (*str - 0x30); | |
| else | |
| break; | |
| str++; | |
| } |
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| Colors = { | |
| :red => [99, 30], | |
| :blue => [10, 99], | |
| :green => [10, 99], | |
| } | |
| def ccalc(min, max, fraction) | |
| min + ((max - min) * fraction) |
This file contains hidden or 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
| diff -Naur pidgin-2.5.5/libpurple/connection.c pidgin-2.5.5-pete/libpurple/connection.c | |
| --- pidgin-2.5.5/libpurple/connection.c 2009-01-24 07:13:25.000000000 -0800 | |
| +++ pidgin-2.5.5-pete/libpurple/connection.c 2009-05-08 16:44:23.000000000 -0700 | |
| @@ -512,16 +512,23 @@ | |
| void | |
| purple_connection_error(PurpleConnection *gc, const char *text) | |
| { | |
| /* prpls that have not been updated to use disconnection reasons will | |
| * be setting wants_to_die before calling this function, so choose | |
| * PURPLE_CONNECTION_ERROR_OTHER_ERROR (which is fatal) if it's true, |
This file contains hidden or 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
| -- Take *that*, retiman! | |
| -- It's my general ignorance of Haskell, or the awfulness of | |
| -- Haskell's SHA1 library, or something. This is the best way I | |
| -- could find to turn whatever that SHA1 library returns into a | |
| -- regular string to compare with other strings. | |
| str2octets = concatMap ((toOctets 256) . ord) | |
| hashString = hash . str2octets |