Skip to content

Instantly share code, notes, and snippets.

View nrk's full-sized avatar
🤔
はい、猫のように見えます。

Daniele Alessandri nrk

🤔
はい、猫のように見えます。
View GitHub Profile
@nrk
nrk / keybase.md
Created June 16, 2014 19:20
keybase.md

Keybase proof

I hereby claim:

  • I am nrk on github.
  • I am nrk (https://keybase.io/nrk) on keybase.
  • I have a public key whose fingerprint is 10FD 7831 4575 D9BE A1AD DE06 6F02 4C0D CE75 5CFF

To claim this, I am signing this object:

@nrk
nrk / runtest.io
Created July 24, 2008 15:42
just a quick test of Io's unit testing facility
// runtest.io
TestSuite clone setPath(System launchPath) run
@nrk
nrk / messageManipulation001.io
Created July 25, 2008 06:50
Message manipulation at runtime in Io
foo := block(str,
str asMutable asCapitalized println
)
foo call("my awesome string") // ==> My awesome string
foo message // ==> str asMutable asCapitalized println
foo message next // ==> asMutable asCapitalized println
foo message next next // ==> asCapitalized println
adaniele@nutcracker:~/ironruby$ mono bin/ir.exe
IronRuby 1.0.0.1 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
Note that local variables do not work today in the console.
As a workaround, use globals instead (eg $x = 42 instead of x = 42).
>>> puts 'hello'
hello
=> nil
//
// File: fsevents_windows.go
// Date: October 29, 2013
// Author: Peter Krnjevic <pkrnjevic@gmail.com>, on the shoulders of many others
//
// This code sample is released into the Public Domain.
//
package fsevents
import (
#
# Original version by Grant Parnell is offline (http://digitaldj.net/2011/07/21/trim-enabler-for-lion/)
# Update July 2014: no longer offline, see https://digitaldj.net/blog/2011/11/17/trim-enabler-for-os-x-lion-mountain-lion-mavericks/
#
# Looks for "Apple" string in HD kext, changes it to a wildcard match for anything
#
# Alternative to http://www.groths.org/trim-enabler-3-0-released/
# Method behind this madness described: http://forums.macrumors.com/showthread.php?t=1409151&page=4
# See discussion in comments here: https://www.macupdate.com/app/mac/39654/lion-tweaks
# And here: http://forums.macrumors.com/showthread.php?t=1410459
@nrk
nrk / tumblr_read_json.io
Created August 20, 2008 14:32
Parsing posts from tumblr using JSON
// Parsing posts from tumblr using JSON
JSON
Regex
Map squareBrackets := method(
return self at(call evalArgs at(0))
)
URL with("http://staff.tumblr.com/api/read/json") fetch findRegex("^var tumblr_api_read = (.*);\s*$") ?at(1) fromJSON ["posts"] foreach(post, post ["type"] println)
@nrk
nrk / tumblr_read_json.lua
Created August 20, 2008 15:13
This is the same as http://gist.github.com/6376 but written in Lua
http = require "socket.http"
require "json"
local json_res = http.request("http://staff.tumblr.com/api/read/json")
local tumblr = json.decode(string.match(json_res, "^var tumblr_api_read = (.*);%s*$"))
for _, post in ipairs(tumblr.posts) do print(post.type) end
--[[ **** OUTPUT ****
@nrk
nrk / gist:8100
Created August 30, 2008 09:13
Win32API.so ported to IronRuby: first (barely) working bits
IronRuby 1.0.0.0 on .NET 2.0.50727.1433
Copyright (c) Microsoft Corporation. All rights reserved.
Note that local variables do not work today in the console.
As a workaround, use globals instead (eg $x = 42 instead of x = 42).
>>> require 'mscorlib'
=> true
>>> require 'Win32API'
=> true
@nrk
nrk / dump_from_irb_console.txt
Created September 2, 2008 18:32
Win32API.so ported to IronRuby
irb(main):001:0> require 'Win32API'
=> true
irb(main):002:0> $get_logical_drives = Win32API.new('kernel32', 'GetLogicalDriveStrings', ['P', 'P'], 'I')
=> #<Win32API:0x2e2a200>
irb(main):003:0> $buffer = ' ' * 32
=> " "
irb(main):004:0> $length = $get_logical_drives.call($buffer.length, $buffer)
=> 16
irb(main):005:0> $buffer
=> "A:\\\000C:\\\000D:\\\000S:\\\000\000 "