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 / 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 / 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 / .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 / 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 / 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 / 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);
package bar
import ( "fmt" )
// should be in a folder called foo
func Bar() {
fmt.Println("bats");
}
01: level1
02: WE5aVWRwYPhX
03: 1MkIE7hhtlXA
04: 1ZwMe9q1nDC9
@ox
ox / add_tag.java
Created April 5, 2012 02:09
AddTag for DOM Tree
public void addTag(String word, String tag) {
recursiveAddTag(root, word, tag);
}
private void recursiveAddTag(TagNode parent, String word, String tag) {
for (TagNode ptr=parent; ptr != null;ptr=ptr.sibling) {
String[] parts = ptr.tag.split(word+"[^\\s\\w]*",2);
if(parts.length > 1) {
System.out.println("operating on: " + java.util.Arrays.toString(parts));
if(ptr.tag.equals(word)) {
@ox
ox / asm_interp.rb
Created March 29, 2012 22:13
An AT&T assembly interpreter. It's not too great but you can do some simple math, as well as print out register values.
# registers
$reg = {eax: 0, ebx: 0, ecx: 0, edx: 0, esi:0, edi: 0, esp: 0, ebp: 0}
$Stack = []
$verbose = false
def gr(term); $reg[term]; end
def valid_reg(term); !$reg[term[1..-1].to_sym].nil?; end
def valid_imm(term); term[1..-1].to_i && term != "$0" ? true : false; end
def eval_asm(line)