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 reads from key presses from a serial device (such | |
# as an arduino) in the following form: | |
# +4-2+11 | |
# this means that the keys 4 and 11 are engaged | |
# and key 2 is not engaged. Use the keys map below | |
# to map keys to midi notes | |
require 'unimidi' | |
require 'serialport' |
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 sketch is a trivial extension of: | |
// http://www.instructables.com/id/Turn-a-pencil-drawing-into-a-capacitive-sensor-for/ | |
// This sketch returns which digital pins | |
// specified in the pins array take 50 or more | |
// cycles to pull high. Pins that take more than | |
// 50 cycles have a + and pins that take less | |
// have a - | |
int pins[] = { | |
2,3,5,6,8,9,11,12 | |
}; |
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
# gem install thread | |
require 'thread/pool' | |
require 'thread/channel' | |
require 'ruby-progressbar' | |
pool = Thread.pool 2 | |
channel = Thread.channel | |
progress = ProgressBar.create totaL: 1_000_000 | |
1_000_000.times do |i| |
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
# the first example in the Spark Quick Start Guide in jRuby | |
# https://spark.apache.org/docs/latest/quick-start.html | |
require './spark-assembly-1.4.0-SNAPSHOT-hadoop2.4.0.jar' | |
conf = org.apache.spark.SparkConf.new | |
conf.setAppName('ruby!').setMaster('local') | |
sc = org.apache.spark.SparkContext.new conf | |
textFile = sc.textFile('README.md', 1) |
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
require 'socket' | |
require 'websocket' | |
require 'websocket-client-simple' | |
port = rand(10_000..60_000) | |
thread = Thread.new do | |
begin | |
server = TCPServer.new port | |
socket = server.accept |
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
comm = IRuby::Comm.new("prompter") | |
comm.open | |
session = IRuby::Kernel.instance.session | |
message = session.instance_eval do | |
unserialize(@sockets[:reply].recv_message) | |
end | |
comm.close |
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
require 'slim' | |
require 'sinatra' | |
template :upload do | |
<<-END | |
head | |
script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" | |
javascript: | |
$(document).ready(function() { | |
$('#upload :button').click(function(){ |
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
{ | |
"load_extensions": { | |
"integration": true, | |
"toolmetrics": true | |
}, | |
"_": "https://codemirror.net/doc/manual.html", | |
"MarkdownCell": { | |
"cm_config": { | |
} | |
}, |
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
{ | |
"NewNotebookWidget": { | |
"default_kernel": "ruby" | |
} | |
} |
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
IPython.CodeCell.options_default.cm_config.autoCloseBrackets = false; | |
setTimeout(function() { | |
if (window.terminal != undefined) { | |
window.terminal.term.screenKeys = true; | |
} | |
}, 1000); |
OlderNewer