Skip to content

Instantly share code, notes, and snippets.

Avatar

Tony Zanella tallenaz

  • Stanford University
  • Stanford, CA
View GitHub Profile
View gist:e199f1191cc656cb8c3d94567d68759a
require 'sparql/client'
sparql = SPARQL::Client.new("http://dbpedia.org/sparql")
sparql.query("SELECT ?album WHERE { ?album dbp:type 'album'@en ; dbo:artist dbr:The_Beatles . }")
# SELECT * WHERE { ?s ?p ?o } OFFSET 100 LIMIT 10
# query = sparql.select.where([:s, :p, :o]).offset(100).limit(10)
# query.each_solution { |solution| puts solution.inspect }
2.2.4 :055 > query = sparql.select(:album).where([:album, 'dbp:type "album"@en ;', 'dbo:artist dbr:The_Beatles'])
=> #<SPARQL::Client::Query:0x3ff07ce42bd4(SELECT ?album WHERE { ?album dbp:type "album"@en ; "dbo:artist dbr:The_Beatles" . })>
View gortek_p32.rb
# a port of
# archive.org/stream/Gortek_and_the_Microchips_1984_Commodore#page/n35/mode/1up
# along with help from
# patshaughnessy.net/2012/2/29/the-joke-is-on-us-how-ruby-1-9-supports-the-goto-statement
__label__(:wrong)
puts "WHAT IS THIS WORD -- SIBAC"
input = gets.chomp
__goto__(:right) if input == "BASIC"
__goto__(:wrong)
__label__(:right)
@tallenaz
tallenaz / naming_bad.rb
Created Mar 18, 2014
Manipulating strings, Breaking Bad style...
View naming_bad.rb
require 'colorize'
periodic_table = %w[H He Li Be B C N O F Ne Na Mg Al Si P
S Cl Ar K Ca Sc Ti V Cr Mn Fe Co Ni Cu
Zn Ga Ge As Se Br Kr Rb Sr Y Zr Nb Mo
Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe Cs
Ba Lu Hf Ta W Re Os Ir Pt Au Hg Tl Pb
Bi Po At Rn Fr Ra Lr Rf Db Sg Bh Hs Mt
Ds Rg Cn Uut Fl Uup Lv Uus Uuo La Ce Pr
Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Ac Th
@tallenaz
tallenaz / gist:4636512
Last active Dec 11, 2015
.vimrc setting to detect file encoding
View gist:4636512
if has("statusline")
set statusline=%<%f\ %y\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P
endif
set fileencodings=ucs-bom,utf-8,sjis,euc-jp,default,latin1