Skip to content

Instantly share code, notes, and snippets.

My writing process

Stages of my writing process

  • Collecting material: For a number of topics that I may write about in the future, I have text files where I collect information as I come across it during coding, on the web, on Twitter, etc.

  • Outline: The collected material is my starting point. I rearrange it into an outline which I refine until I’m happy with it. Refining includes adding/removing/rearranging items and doing more research when I notice gaps in my knowledge.

  • Skeletal draft: I add bullet points and code examples until almost all of the content exists at least in skeletal form. This process often uncovers knowledge gaps and flaws in the structure of the content which I then can fix.

@tekin
tekin / .gitattributes
Last active February 23, 2024 16:46
An example .gitattributes file that will configure custom hunk header patterns for some common languages and file formats. See https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more for more details.
# Stick this in your home directory and point your Global Git config at it by running:
#
# $ git config --global core.attributesfile ~/.gitattributes
#
# See https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more for more details
*.c diff=cpp
*.h diff=cpp
*.c++ diff=cpp
*.h++ diff=cpp
@fernandoaleman
fernandoaleman / mysql2-mojave.md
Last active February 7, 2024 19:19
Install mysql2 on MacOS Mojave

For MacOS Catalina, visit Install mysql2 on MacOS Catalina

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

@itsgoingd
itsgoingd / das_download.rb
Created August 5, 2018 15:11
Script to download all Destroy All Software screencasts w/ login (works as of Aug 2018)
#! /usr/bin/env ruby
# usage:
# $ das_download.rb email password
# based on various gists from this thread https://gist.github.com/maca/1798070
require "mechanize"
require "fileutils"
class DasDownloader
attr_reader :agent, :email, :password
@taxigy
taxigy / fn-comp.clj
Created March 7, 2018 00:03
Haskell vs Clojure: function composition — Learn You a Haskell for Great Good!
;; without composition
(repeat 2 (apply * (map #(* 3 %) (map max [1 2] [4 5]))))
;; with composition
((comp (partial repeat 2)
(partial apply *)
(partial map (partial * 3)))
(map max [1 2] [4 5]))
;; with thread macro
@joyrexus
joyrexus / README.md
Last active February 24, 2024 15:16
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@wrburgess
wrburgess / example_job.rb
Last active April 6, 2020 20:17
ActiveJob on Rails 5 with RSpec
# app/jobs/example_job.rb
class ExampleJob < ActiveJob::Base
queue_as :default
rescue_from(ActiveRecord::RecordNotFound) do
retry_job wait: 1.minute, queue: :default
end
def perform(param_1, param_2)
@kares
kares / slow_query_log.rb
Last active March 23, 2022 09:40
ActiveRecord slow query logging in Rails ... setup using: config.slow_query_log_threshold_in_ms = 500
require 'active_record/log_subscriber'
class SlowQueryLog < ActiveSupport::LogSubscriber
if Rails.configuration.respond_to?(:slow_query_log_threshold_in_ms)
if @@threshold = Rails.configuration.slow_query_log_threshold_in_ms
@@threshold = @@threshold.to_i == 0 ? nil : @@threshold.to_i
end
else
@@threshold = nil
#$null_stream = $stdout
$null_stream = File.open(File::NULL, 'w')
require 'rspec'
def start_runner
RSpec::Core::Runner.run [], $null_stream, $null_stream
end
tp = TracePoint.new(:inline_cache_hit, :inline_cache_miss) do |x|
p x.event
@pirj
pirj / ruby-block-sugar.asciidoc
Last active July 29, 2022 14:19
Ruby block sugar

You won’t find rants on how functional programming improves you, your sanity and your life overall here. There are some examples in the very beginning to save you some time on reading the whole post, just come along if you don’t like how they look like.

By the way, this is not even a blog, so formally this is not even a blog post. This is not a library or a new paradigm. It’s just a few pieces of code that might come handy for your daily job.

Example:

[1, 3.14, -4].map &_.safe{ magnitude odd? } # => [true, nil, false]