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 / 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 / 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 / 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 / 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 / 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 / index.txt
Created December 11, 2012 11:29
blog index
4150501
4257911
@ox
ox / foo.md
Created December 11, 2012 11:30
The Rise of Foo

The Rise of Foo

  def hello(world)
    puts world
  end
  
  def bar(color)
    puts "I love #{color}"
 end
@ox
ox / index.md
Created December 11, 2012 22:31
Syntax Highlighting Check in gist.io

Can gist.io actually do syntax highlighting?

Lets check:

def foo(bar)
  puts "foo #{bar}"
  sleep(1)
end
@ox
ox / client.h
Created December 12, 2012 23:51
the client struct
#ifndef _CLIENT_H
#define _CLIENT_H
#include "order.h"
struct Client {
char * name;
int id;
double credit;
@ox
ox / pages.py
Created December 17, 2012 23:05
import sys
from os.path import exists
import subprocess
import re
# Calls the R system specifying that commands come from file commands.R
# The commands.R provided with this assignment will read the file named
# data and will output a histogram of that data to the file pageshist,pdf
def runR( ):
res = subprocess.call(['R', '-f', 'commands.R'])