Skip to content

Instantly share code, notes, and snippets.

@caseywatts
caseywatts / 0-self-publishing.md
Last active October 5, 2024 11:27
Self-Publishing via Markdown
@ricmarinovic
ricmarinovic / guess.ex
Last active July 5, 2019 00:18
guess number
defmodule Playground do
def guess(actual, a..b) do
do_guess(actual, a..b, div(b, 2))
end
def do_guess(actual, a.._b, number) when actual < number do
print_number(number)
do_guess(actual, a..number, div(a + number, 2))
end
ExUnit.start()
defmodule ChopTest do
use ExUnit.Case, async: true
test "Should return guessed number" do
teste = Chop.guess(273, 1..1000)
assert teste == 273
end
@kule
kule / mini_rspec.rb
Created September 11, 2018 09:37
Simplified example of how rspec works
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'colorize'
end
class MatcherInterface
def initialize(some_object)
@some_object = some_object
@jasonrdsouza
jasonrdsouza / combineS3Files.py
Last active June 3, 2023 17:22
Python script to efficiently concatenate S3 files
'''
This script performs efficient concatenation of files stored in S3. Given a
folder, output location, and optional suffix, all files with the given suffix
will be concatenated into one file stored in the output location.
Concatenation is performed within S3 when possible, falling back to local
operations when necessary.
Run `python combineS3Files.py -h` for more info.
'''
@Integralist
Integralist / Ruby Lambdas.md
Last active August 8, 2023 05:10
Ruby lambdas

Lambda: standard

# Creating a lambda
l = lambda { |name| "Hi #{name}!" }

# Executing the lambda
l.call("foo") # => Hi foo!
@schickling
schickling / Rakefile
Last active November 5, 2024 09:14
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)
@chetan
chetan / yardoc_cheatsheet.md
Last active November 11, 2024 08:27
YARD cheatsheet