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
# add headers | |
$ echo ‘#include “Arduino.h”’ > blink.cpp | |
# add sketch | |
$ cat blink.ino >> blink.cpp | |
# add int main() | |
$ cat /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/main.cpp >> blink.cpp | |
# build binary |
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
function allMovies() { | |
return client.smembersAsync('movies.ids').then(function(ids) { | |
var movies = _.map(ids, function(id) { | |
return client.hmgetAsync("movies:" + id, 'title', 'description', 'director', 'year').then(function(data) { | |
return { | |
title: data[0], | |
description: data[1], | |
director: data[2], | |
year: data[3] | |
}; |
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
var iconv_latin1 = new Iconv('latin1', 'utf-8'); | |
assert.deepEqual(iconv_latin1.convert("L��nitz"), "Lößnitz"); | |
assert.js:92 | |
throw new assert.AssertionError({ | |
^ | |
AssertionError: [76,195,175,194,191,194,189,195,175,194,191,194,189,110,105,116,122] deepEqual "Lößnitz" | |
at Object.<anonymous> (/Users/pmu/projects/github/node-iconv/test/test-basic.js:37:8) | |
at Module._compile (module.js:456:26) | |
at Object.Module._extensions..js (module.js:474:10) |
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
var fs = require("fs"); | |
var stream = fs.createReadStream("test.xml", {encoding: "UTF-8"}); | |
var out = fs.createWriteStream("out.json", {encoding: "UTF-8"}); | |
var sax = require("sax"); | |
var parser = sax.createStream(true); | |
parser.on("opentag", function (node) { | |
console.log(node.name); | |
out.write("\n"); | |
}) |
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
f = File.new("u.item_utf8") | |
ls = f.readlines | |
puts "[" | |
ls.each do |l| | |
fs = l.split("|") | |
/(.*) \((\d+)\)$/.match(fs[1]) | |
title = $1 | |
year = $2 |
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
1) SignupPresenter#save saves records when there are valid | |
Failure/Error: User.count.should be 1 | |
expected #<Fixnum:3> => 1 | |
got #<Fixnum:5> => 2 | |
Compared using equal?, which compares object identity, | |
but expected and actual are not the same object. Use | |
`expect(actual).to eq(expected)` if you don't care about | |
object identity in this example. |
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
var url = require('url'); | |
var _ = require('underscore'); | |
var querystring = require('querystring'); | |
var Promise = require("bluebird"); | |
//assume client is a redisClient | |
// | |
var now = (typeof Date.now === 'function')? Date.now : function(){ | |
return +(new Date()); |
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
[ | |
{ | |
"id": 12, | |
"genres": [ | |
"Drama", | |
"Comedy" | |
], | |
"rating": 0, | |
"description": "A silent movie star meets a young dancer, but the arrival of talking pictures sends their careers in opposite directions.", | |
"title": "The Artist", |
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
function createUser(raw, success_cb, fail_cb) { | |
var userId; | |
console.log("enter"); | |
async.waterfall([ | |
function(cb) { | |
// Increase | |
client.hincrby('users', 'count', 1, cb); |
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
server = Stretcher::Server.new('http://localhost:9200', :log_level => :debug) | |
server.index(:moviesdb1).create(mappings: {movie: {properties: {title: {type: 'string'}, genres: {type: 'string', index_name: 'genre1'}}}}) | |
# [Stretcher][DEBUG]: curl -XPUT http://localhost:9200/moviesdb1 -d '{"mappings":{"movie":{"properties":{"title":{"type":"string"},"genres":{"type":"string","index_name":"genre1"}}}}}' '-H Accept: application/json' '-H Content-Type: application/json' '-H User-Agent: Stretcher Ruby Gem 1.20.0.beta1' | |
# => #<Hashie::Mash acknowledged=true ok=true> | |
server.index(:moviesdb1).type(:movie).put(1, { title: 'The Artist', genres: ['Drama', 'Comedy']}) | |
server.index(:moviesdb1).type(:movie).put(2, { title: 'Taxi Driver', genres: ['Drama', 'Action']}) |
NewerOlder