$ rails g model User
belongs_to
has_one
# ========================================= | |
# A toy text editor written in CoffeeScript | |
# ========================================= | |
# | |
# Requires ncurses bindings for node.js: | |
# npm install ncurses | |
# | |
# Usage: | |
# coffee editor.coffee FILENAME | |
# |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Mathieu 'p01' Henri - http://www.p01.org/releases/ | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
require 'rest_client' | |
require 'json' | |
a = `sox -d --norm -t .flac - silence -l 1 0 1% 1 6.0 1% rate 16k` | |
#a = `arecord -q -d 3 -c 1 -f S16_LE -r 22050 -t wav | flac - -f --totally-silent -o-` | |
r = RestClient.post 'https://www.google.com/speech-api/v1/recognize?lang=en-US', a, | |
:content_type => 'audio/x-flac; rate=16000' | |
if j = JSON.parse(r) | |
(p j; `espeak 'you said: #{j['hypotheses'].first['utterance']}'`) | |
end |
#!/usr/bin/env ruby | |
require 'socket' | |
require 'openssl' | |
require "base64" | |
server = "some-irc.tld" | |
port = "6667" | |
nick = "Nickname#{rand(5000)}" | |
channel = "#channel" |
class Lisp | |
def initialize | |
@env = { | |
:label => lambda { |(name,val), _| @env[name] = val }, | |
:quote => lambda { |sexpr, _| sexpr[0] }, | |
:car => lambda { |(list), _| list[0] }, | |
:cdr => lambda { |(list), _| list.drop 1 }, | |
:cons => lambda { |(e,cell), _| [e] + cell }, | |
:eq => lambda { |(l,r), _| l == r }, | |
:if => lambda { |(cond, thn, els), ctx| eval(cond, ctx) ? eval(thn, ctx) : eval(els, ctx) }, |
import re, sys, operator | |
#read and tokenize the program | |
tokens = [x for x in re.split(r'\s+', re.sub('([()])', r' \1 ', ''.join((sys.stdin.readlines())))) if x] | |
#populate the global scope | |
global_scope = None, {'+': lambda nums: sum(map(apply, nums)), '-': lambda nums: -nums[0]() if len(nums)==1 else nums[0]() - sum(map(apply, nums)[1:]), | |
'/': lambda nums: nums[0]() / nums[1](), '*': lambda nums: reduce(operator.mul, map(apply, nums)), | |
'equal?': lambda exprs: 'true' if exprs[0]() == exprs[1]() else 'false', | |
'if': lambda exprs: exprs[1]() if exprs[0]()=='true' else exprs[2]()} |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
/usr/bin/cpp -P -undef -Wundef -std=c99 -nostdinc -Wtrigraphs -fdollars-in-identifiers -C < foo.js |
The bridge is now located at https://github.com/fjolnir/TLC |