Skip to content

Instantly share code, notes, and snippets.

View ox's full-sized avatar
👹
what is this, AIM?

Artem Titoulenko ox

👹
what is this, AIM?
View GitHub Profile
@ox
ox / index.txt
Created December 11, 2012 11:29
blog index
4150501
4257911
@ox
ox / app.js
Created November 26, 2012 20:43
// the module needs to be `define`'d. If the `require([])` syntax is used, then the async method NEEDS to be used.
define(['jquery', 'underscore', 'backbone'], function($, _, Backbone) {
console.log("running the app...");
var initialize = function(){
// Pass in our Router module and call it's initialize function
console.log("initializing from inside the app");
};
return {
@ox
ox / gitcal.rb
Created November 14, 2012 04:54
A commit-based calendar. If a commit was made on a day, that day is green, otherwise red.
require 'date'
require 'time'
require 'colored'
time = Date.today
puts time.strftime("%B %Y").center(20)
puts "Su Mo Tu We Th Fr Sa"
sday = Date.new(time.year, time.month, 1)
days_in_month = (Date.new(time.year, 12, 31) << (12-time.month)).day
@ox
ox / clean_prime_chain.rb
Created November 12, 2012 07:09
Math-y challenge from http://www.zerocater.com/challenge/, find length of sequence of primes where the sum of the N-1 elements is divisible by the Nth element.
require 'prime'
prime_tester = Prime.instance
n = 3
sum = 2
len = 1
loop do
if prime_tester.prime? n
len = len + 1
@ox
ox / cal.rb
Created November 12, 2012 04:18
A calendar drawer for the current month in the terminal
require 'date'
time = Date.today
# print month, year header
puts time.strftime("%B %Y").center(20)
# print th days of the week
puts "Su Mo Tu We Th Fr Sa"
@ox
ox / page_title_changer_example.rb
Created November 1, 2012 22:04
a sample page replacement server that can handle title changes
require 'siantra'
require 'redis'
$redis = Redis.new
get "/edit/:title" do |title|
page = $redis.hgetall("posts:by_title:#{title}")
erb :edit_page, locals: {page: page}
end
@ox
ox / .tmux.conf
Created November 1, 2012 02:34
my tmux config
# status bar
set-option -g status-utf8 on
set -g status-interval 1
# C-b is not acceptable -- Vim uses it
set-option -g prefix C-a
bind-key C-a last-window
# quick pane killing
@ox
ox / lispy_rake.rb
Created October 31, 2012 23:17
A Rakefile for making lispyscript projects. Needs 2 directories, src and bin
task default: [:make_all]
root = Dir.pwd
src = ENV["src"] || "src"; src_dir = File.join(root, src)
bin = ENV["bin"] || "bin"; bin_dir = File.join(root, bin)
main = ENV["main"] || "main"
def make(file_name, dir_out="bin")
Dir.mkdir(dir_out) unless File.directory?(dir_out)
res = `lispy #{file_name}.ls #{File.join(dir_out, file_name)}.js`
@ox
ox / clean-redis-playlist.rb
Created October 29, 2012 19:21
One way to use classes to facilitate cleaner interactions with Redis as the main "database"
class Playlist
def initialize(playlist={})
return nil unless playlist["tracks"] and playlist["author"]
num = $redis.incr("playlists:num")
next_id = $redis.incr("playlists:next_id")
$redis.sadd("playlists:all", next_id)
playlist["date"] = Time.now
playlist["id"] = next_id
@ox
ox / primes.rb
Created October 11, 2012 15:36
Find primes, but using the ruby stdlib
require 'prime'
100.times { |n| puts n if n.prime? }