Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am hamled on github.
  • I am hamled (https://keybase.io/hamled) on keybase.
  • I have a public key whose fingerprint is 4F35 1CAF 0D0B 1D00 9CE4 CCF6 4265 F9D0 9BC1 D7EA

To claim this, I am signing this object:

@Hamled
Hamled / advanced_variables.txt
Created October 6, 2015 21:41
Terminal sessions from 10/06/2015 lectures
## Talking about Local Variables and Instance Variables
097 >local_variable = 10
=> 10
098 >@instance_variable = "hi"
=> "hi"
099 >Local_variable = 10
=> 10
100 >Local_variable
=> 10
101 >def bob
@Hamled
Hamled / bash_output.txt
Last active October 13, 2015 16:57
RSpec Introduction Examples
$ rspec spec
.
Finished in 0.00121 seconds (files took 0.17275 seconds to load)
1 example, 0 failures
@Hamled
Hamled / chair.rb
Created October 13, 2015 21:50
RSpec Example - Chair class
class Chair
def stack(another_chair)
if another_chair.nil?
return [self]
elsif another_chair.is_a? Chair
return [another_chair, self]
else
return another_chair.push(self)
end
end
def find_movies(flight_length, movie_lengths)
movie_complements = Set.new
movie_lengths.each do |movie_length|
# We have a good movie pair if this length is the complement of a previous movie's length
return true if movie_complements.include? movie_length
# Otherwise, track the complement of this movie's length for checking against succeeding movie lengths
movie_complements << (flight_length - movie_length)
end
@Hamled
Hamled / _README_.md
Last active December 22, 2015 07:45
Advent of Code 2015

Advent of Code 2015

http://adventofcode.com/

My Attempts

For this coding challenge/exercise I decided to restrict myself to only single-line responses. In order to achieve this I employ shell scripting to download the problem input, and Ruby code passed directly to an interpreter in order to transform it.

More important than the literal single-line nature of the code is the single "statement" aspect. I've prefered to use Ruby features and library methods that chain together, resulting in one long run-on

@Hamled
Hamled / md5substr.c
Last active December 21, 2015 22:14
Finding MD5 hash collisions with specific plaintext prefix
/*
* generate collisions for truncated md5 hashes
* e.g., substr(md5($pass), 0, 8)
* cc -o md5substr md5substr.c -march=native -O3 -funroll-loops -pthread
*
* Copyright 2013, epixoip. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
@Hamled
Hamled / md5substr.c
Created December 21, 2015 22:16
Finding MD5 hash collisions with specific plaintext prefix
/*
* generate collisions for truncated md5 hashes
* e.g., substr(md5($pass), 0, 8)
* cc -o md5substr md5substr.c -march=native -O3 -funroll-loops -pthread
*
* Copyright 2013, epixoip. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
@Hamled
Hamled / petstore.xml
Created January 9, 2016 00:45
Two different ways to convert an XML document to JSON
<petStore>
<pets>
<dog>
<id>515</id>
<name>Rusty</name>
<breed>ChocolateLabrador</breed>
</dog>
<dog>
<id>516</id>
<name>Lulu</name>
# FIRST edit the next line to have the path to your project-forks folder
# Something like ~/Desktop/ada/project-forks
export PROJECTS=~/path/to/your/project-forks
# THEN run these lines (unmodified)
brew install python
pip install virtualenv
pip install virtualenvwrapper
echo "export WORKON_HOME=~/.virtualenvs" >> ~/.bashrc