Skip to content

Instantly share code, notes, and snippets.

Avatar
🗣️
play stupid games / win stupid prizes

Patrick Thomson patrickt

🗣️
play stupid games / win stupid prizes
View GitHub Profile
View gist:48546
$("div"); // all div elements
$("span.moveable") // all spans with the moveable class
$("em,strong"); // all emphasized and strong tags
$("div\[img][3]"); // the third div that contains an image
View gist:48721
module Main where
import Data.Array
import Data.Char
import Debug.Trace
import System.IO
type Memory = Array Int Int
changeMemory :: Memory -> Int -> Int -> Memory
View gist:48754
(require srfi/1)
(define || (lambda (x y) (or x y)))
(define && (lambda (x y) (and x y)))
(define -->
(lambda (x y)
(not (and x (not y)))))
(define interpret
(lambda (f)
View gist:76994
static VALUE
io_write(VALUE io, SEL sel, VALUE to_write)
{
rb_io_t *io_struct;
VALUE to_write;
UInt8 *buffer;
CFIndex length;
rb_secure(4);
View gist:76998
static VALUE
io_write(VALUE io, VALUE str)
{
rb_io_t *fptr;
long n;
VALUE tmp;
rb_secure(4);
io = GetWriteIO(io);
str = rb_obj_as_string(str);
View gist:80735
Index: io.c
===================================================================
--- io.c (revision 953)
+++ io.c (working copy)
@@ -102,6 +102,20 @@
// return S_ISSOCK(sbuf.st_mode);
// }
+
+static int extract_mode_flags(VALUE mode_string) {
View gist:82574
Index: io.c
===================================================================
--- io.c (revision 1023)
+++ io.c (working copy)
@@ -865,6 +865,24 @@
return data_read;
}
+static VALUE
+rb_io_read_all(rb_io_t *io_struct, VALUE bytestring_buffer)
View gist:83807
./miniruby -v -I./mspec/lib -I./lib ./mspec/bin/mspec-run spec/frozen/language/and_spec.rb spec/frozen/language/case_spec.rb spec/frozen/language/execution_spec.rb spec/frozen/language/hash_spec.rb spec/frozen/language/if_spec.rb spec/frozen/language/module_spec.rb spec/frozen/language/numbers_spec.rb spec/frozen/language/or_spec.rb spec/frozen/language/order_spec.rb spec/frozen/language/unless_spec.rb spec/frozen/language/until_spec.rb spec/frozen/language/while_spec.rb
(eval):2: syntax error, unexpected keyword_else, expecting keyword_when
(eval):2: syntax error, unexpected keyword_else, expecting keyword_when
(eval):1: no .<digit> floating literal anymore; put 0 before dot
(eval):1: syntax error, unexpected '.'
(eval):1: no .<digit> floating literal anymore; put 0 before dot
(eval):1: syntax error, unexpected '.'
rake aborted!
Command failed with status (1): [./miniruby -v -I./mspec/lib -I./lib ./mspe...]
View gist:90361
rb_io_s_open(VALUE klass, SEL sel, int argc, VALUE *argv)
{
printf("Beginning the opening lol.");
VALUE io = rb_io_s_new(klass, sel, argc, argv);
if (rb_block_given_p()) {
VALUE ret = rb_vm_yield(1, &io);
rb_io_close_m(io, 0);
return ret;
}
return io;
View gist:115109
int
main(int argc, char * const argv[])
{
printf("void* is %d bits wide\n", sizeof(void*) * 8);
printf("int is %d bits wide\n", sizeof(int) * 8);
printf("long is %d bits wide\n", sizeof(long) * 8);
printf("long long is %d bits wide\n", sizeof(long long) * 8);
printf("float is %d bits wide\n", sizeof(float) * 8);
printf("double is %d bits wide\n", sizeof(double) * 8);
printf("long double is %d bits wide\n", sizeof(long double) * 8);