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 / server.js
Created July 21, 2012 17:15
Config that Node for different environments
var express = require('express'),
http = require('http'),
redis = require('redis'),
argv = require('optimist').default('env', 'default').options('c', { 'alias' : 'config'
, 'default' : './default_config.json'
}).argv
, config = require(argv.config);
var app = express();
var server = http.createServer(app);
@ox
ox / 01connection_attempts.txt
Created July 24, 2012 01:42
Bot spam when exposing a server using localtunnel. The account attempts to send "invoice.payment_succeeded" and "charge.succeeded" events to the server in hopes of getting free content. I
This is a series of POST requests that were made on my server in a matter of a few minutes. It seems to be sending different events, pretending something was bought using facebook credits and hoping the server will respond in agreement. I may be wrong but that's what it looks like. The account in question is 1527602990
Started POST "/hooks/receive" for 127.0.0.1 at 2012-07-23 21:23:35 -0400
Processing by ErrorsController#rescue_from_routing_error as XML
Parameters: {"object"=>"event", "type"=>"invoice.updated", "created"=>1343041707, "data"=>{"object"=>{"period_end"=>1342782211, "paid"=>true, "period_start"=>1340190211, "subtotal"=>2499, "customer"=>"cus_R60CriMU296q1f", "ending_balance"=>0, "attempt_count"=>1, "discount"=>nil, "attempted"=>true, "next_payment_attempt"=>nil, "object"=>"invoice", "closed"=>true, "date"=>1342782352, "starting_balance"=>0, "amount_due"=>2499, "livemode"=>false, "lines"=>{"invoiceitems"=>[], "subscriptions"=>[{"plan"=>{"object"=>"plan", "currency"=>"usd", "livemode"=>false, "a
@ox
ox / decent_is_good.md
Created July 24, 2012 02:32
Being Decent is Good

I'm not quite sure why I decided to write to you in response to your blog post; I usually don't. I think you struck upon an old train of thought that I once had when I was about your age that I revisit every now and then (not that I'm far off being 20). I was never content with what I knew in the field of computer science. I've been programming since I was around 14 and I always thought that I was 7 years too late to becoming great. I believed that anyone who was good had been doing it since their birth and I was just mucking around. That thought brought upon a grim burden that I glanced at every now and then whenever I'd find myself writing code. It's not pleasant, I know, however it's a necessary burden for people like us; those striving for greatness while it appears to bless those around us.

It's a burden you will carry for a few more years as you transition into a university and begin to make actual decisions about your life; decisions with a potentially fatal outcome. You will look around at your peer

@ox
ox / .vimrc
Created September 30, 2012 06:56
my vimrc
call pathogen#infect()
""
"" Basic Setup
""
set nocompatible " Use vim, no vi defaults
set number " Show line numbers
set ruler " Show line and column number
syntax enable " Turn on syntax highlighting allowing local overrides
@ox
ox / tasks.rb
Created October 6, 2012 18:07
A ruby CLI program to manage tasks
File.open("text.txt", "a+") do |f|
f.seek(0)
tasks = f.lines.to_a
tasks.delete_at(ARGV[1].to_i) if ARGV[0] == "d" and !ARGV[1].nil? and ARGV[1].to_i
tasks << ARGV.join(" ") unless ARGV[0] == "d" or ARGV.empty?
File.open("text.txt", "w") {|g| g.puts tasks; tasks.each_with_index {|t, i| puts "#{i}: #{t}"} }
end
@ox
ox / primes.rb
Created October 10, 2012 18:47
find the first 10 primes
(1..10).each do |n|
prime = true
(2..n-1).each do |x|
prime = false if n % x == 0
end
puts n if prime
end
@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? }
@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 / 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 / .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