Skip to content

Instantly share code, notes, and snippets.

View theoretick's full-sized avatar

Lucas Charles theoretick

View GitHub Profile
@theoretick
theoretick / upgrade_postgresql_9.3_to_9.4.sh
Last active March 2, 2016 19:03
shell script for upgrading postgres 9.3 to 9.4 with postGIS. RUN AS ROOT
#! /bin/bash
#
# Based on http://www.gab.lc/articles/migration_postgresql_9-3_to_9-4
#
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@theoretick
theoretick / private_imports.ex
Last active March 2, 2016 18:40
Private imports in ruby versus elixir
iex(1)> defmodule Foo do
...(1)> defp bar do
...(1)> "bar"
...(1)> end
...(1)> end
iex:2: warning: function bar/0 is unused
{:module, Foo,
<<70, 79, 82, 49, 0, 0, 3, 168, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 94, 131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115, 95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>,
{:bar, 0}}
iex(2)> defmodule Derp do
#!/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
{
"hobbies": [
{
"name": "piano",
"tags": [ "#music" ]
},
{
"name": "kickboxing",
"tags": [ "#sports" ]
},
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();
@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",
@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 / 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 »
(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 / 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: