Skip to content

Instantly share code, notes, and snippets.

@chetan
chetan / yardoc_cheatsheet.md
Last active May 10, 2024 02:53
YARD cheatsheet
@schickling
schickling / Rakefile
Last active July 23, 2024 11:19
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)
@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!
@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.
'''
@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
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
@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
@caseywatts
caseywatts / 0-self-publishing.md
Last active June 4, 2024 20:23
Self-Publishing via Markdown