Skip to content

Instantly share code, notes, and snippets.

View theoretick's full-sized avatar

Lucas Charles theoretick

View GitHub Profile
####################################################
# Rspec matchers/expectations
####################################################
##USE EXPECT(foo) NOT (foo).SHOULD
```ruby
expect(foo).to eq(bar)
@theoretick
theoretick / keybase.md
Created June 12, 2014 21:42
keybase.io public identity proof

Keybase proof

I hereby claim:

  • I am theoretick on github.
  • I am theoretick (https://keybase.io/theoretick) on keybase.
  • I have a public key whose fingerprint is 6839 D1A6 800A 1A8F F526 3A62 9860 6992 9D4D 5531

To claim this, I am signing this object:

(defn prob3 [target]
(let [factorials [] biggest target]
(dotimes [num target]
(if-not (or (contains? [0, 1] num) (> num biggest))
(if (= (rem target num) 0)
(recur [(/ biggest num)
(if-not (contains? factorials num)
(def factorials (conj factorials num)))
@theoretick
theoretick / dump_to_yaml.rb
Last active August 29, 2015 14:06
Howto dump ruby to yaml file
[6] website » data = ['foo','bar']
[7] website » require 'yaml'
=> false
[8] website » File.open('foobar_dump.yml','w') do |f|
» YAML.dump(data, f)
» end
=> nil
[9] website »
@theoretick
theoretick / race_condition_tester.sh
Last active December 25, 2016 17:03
test for random failures in your test suite with a simple bash for loop
$ for i in `seq 20`; do bundle exec rescue rspec spec/services/seed_service_spec.rb; done
@theoretick
theoretick / Preferences.sublime-settings
Last active April 1, 2021 15:29
My Sublime Text config
{
"auto_match_enabled": false,
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
extern crate hla_rs;
extern crate image;
use hla_rs::extensions;
use image::GenericImage;
use image::ImageBuffer;
fn main() {
let path = &Path::new("/Users/theoretick/code/rust/hla_rs/Test.png");
let img = image::open(path).unwrap();
{
"hobbies": [
{
"name": "piano",
"tags": [ "#music" ]
},
{
"name": "kickboxing",
"tags": [ "#sports" ]
},
#!/usr/bin/env ruby
# generate a growing value for each letter (in this case its place in the alphabet, e.g. j == 9)
# for each character in the string take the index position of the character (where it is in the
# string) and save that value + 1 with the character. Indexes always start w/ zero, that's why
# we need to add 1. `map` means for each value we produce, save them all and return them together.
letters_with_numeric_values = 'abcdefghijklmnopqrstuvwxyz'.chars.each_with_index.map do |letter, i|
[letter, i+1]
end