Skip to content

Instantly share code, notes, and snippets.

@cronin101
cronin101 / fizzbuzz_hardmode.c
Last active December 19, 2015 07:39
FizzBuzz from 1 to N (supplied as command-line argument) and exiting gracefully without using loops, conditionals, or segfaults - in C.
#include <stdio.h>
#include <stdlib.h>
int i(const int i) { printf("%d\n", i); return i; }
int f(const int i) { printf("Fizz\n"); return i; }
int b(const int i) { printf("Buzz\n"); return i; }
int fb(const int i) { printf("FizzBuzz\n"); return i; }
int (* PC[15])(int i) = { i,i,f,i,b,f,i,i,f,b,i,f,i,i,fb }; // Printer Cycle
int go(const int arg) {
@cronin101
cronin101 / .vimrc
Last active December 19, 2015 19:49
.vimrc and bundle folder
" Load ~/.vim/bundle packages.
call pathogen#infect()
call pathogen#helptags()
" Use Vim defaults
set nocompatible
" Colorscheme settings.
syntax enable
set t_Co=256
@cronin101
cronin101 / invoke.sh
Created July 17, 2013 09:25
OneTrueConfig
git clone git@github.com:cronin101/OneTrueConfig.git --recursive && cd OneTrueConfig && ./install.rb
@cronin101
cronin101 / plot.rb
Last active December 20, 2015 12:39
Graph plotting code example.
#!/usr/bin/env ruby
require 'asymptotic'
class Array
def custom_uniq_1
new_array = []
each do |elem| # you call each method on self here
new_array << elem unless new_array.include?(elem)

ersatz bibimbap

bibimbap as i make it is basically

  • rice
  • sitr fried vegetables
  • some meat in tasty spices
  • gochujang (this is fermented soy bean paste with paprika)
  • a fried egg
@cronin101
cronin101 / Benchmark.rb
Created August 30, 2013 14:03
Benchmark1
#!/usr/bin/env ruby
require './hadope'
require 'benchmark'
puts "Problem, mapping an addition (or two) to a large Array"
Hadope::set_device Hadope::CPU
input = (1..10_000_000).to_a
ruby = Benchmark.realtime {
last = input.map { |i| i + 1 }.map { |j| j + 1 }.last
@cronin101
cronin101 / lesson.md
Last active December 22, 2015 03:38 — forked from tef/lesson.md

I hate markdown

  1. Here is a list. I can do numbered lists.

  2. I can do a list entry followed by two spaces.
    This means this is in the same paragraph

  3. If I want a code block (with syntax highlighting, inside a list, something breaks:

        print("This needs a blank line before the code block")
@cronin101
cronin101 / one_way.rb
Created September 2, 2013 23:22
Trapdoor method
main ⭔ define_method :secret_message, ->{ ->{ define_method :secret_message, ->{ "Too late" } }.() && "I hope you remember this" }
#=> #<Proc:0x007fb74ad90f68@(pry):21 (lambda)>
main ⭔ secret_message
#=> "I hope you remember this"
main ⭔ secret_message
#=> "Too late"
@cronin101
cronin101 / YOQO.rb
Created September 2, 2013 23:24
You only qux once
main ⭔ define_method :qux_it!, ->{ ->{ define_method :qux_it!, ->{ raise "Already quxxed it bro" } }.() && "Quxxing the foo-bar" }
#=> #<Proc:0x007fb75035b1f0@(pry):24 (lambda)>
main ⭔ qux_it!
#=> "Quxxing the foo-bar"
main ⭔ qux_it!
#RuntimeError: Already quxxed it bro
#from (pry):24:in `block (3 levels) in __pry__'
main ⭔ qux_it!
#RuntimeError: Already quxxed it bro
#from (pry):24:in `block (3 levels) in __pry__'
@cronin101
cronin101 / largest_slice.hs
Last active December 23, 2015 06:19
Finding the slice of an input array that has the largest total
import Data.List
data SummedIntList = SummedIntList {
listElements :: [Int],
elementTotal :: Int
} deriving (Show)
emptySummedList = SummedIntList [] 0
addIntToList (SummedIntList xs t) x = SummedIntList (xs ++ [x]) (t + x)