Software is layered.
Documentation is not. If your documentation states
Run
npm install foo
to install this module
It is really saying
Sometimes you need to iterate over a ton of items and you don't want the overhead of creating AR objects out of all of them. Hell, you only need a few things! Well, #pluck has your back.
But what if you want to iterate over many tonnes of items?
Pluck in batches to the rescue!
Enjoy!
# ======================================= | |
# OS X — ONE CLICK — EJECT ALL DISKS | |
# ======================================= | |
# Open Script Editor on OS X | |
# Copy and paste this file in | |
# Pre-High Sierra: Save As > Application | |
# High Sierra: Export > File Format > Application | |
# Name it "Eject All Disks" | |
# Drag created application to Dock | |
# Now you can eject all external disks with one click from Dock |
Spurred by recent events (https://news.ycombinator.com/item?id=8244700), this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.
For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.
But Semantic Versioning (henceforth, SemVer), as specified at http://semver.org/, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.
SemVer tries to compress a huge amount of information — the nature of the change, the percentage of users that wil
Add the utf8_sanitizer.rb to your Rails 3.2 project in app/middleware. Instead of removing the invalid request characters and continuing the request (as some gems do) it returns a 400 error.
Add the following line to your config/application.rb:
config.middleware.use 'Utf8Sanitizer'
If you only need it in production add to config/environments/production.rb. This can be without quotes:
config.middleware.use Utf8Sanitizer
require 'redcarpet' | |
desc "generate index.html from README.md" | |
file "index.html" => "README.md" do |task| | |
puts "Processing README.md to generate a new index.html..." | |
# `r` means we're using the "read" mode with the file | |
# we need a String for Redcarpet, it doesn't accept File objects. | |
string = File.open(task.prerequisites.first, 'r') { |file| file.read } | |
markdown = ::Redcarpet::Markdown.new(Redcarpet::Render::HTML, extensions = {}) |
diff --git i/hash.c w/hash.c | |
index 007508a..6f39e47 100644 | |
--- i/hash.c | |
+++ w/hash.c | |
@@ -2402,6 +2402,28 @@ rb_hash_flatten(int argc, VALUE *argv, VALUE hash) | |
return ary; | |
} | |
+static int | |
+hash_contain_i(VALUE key, VALUE value, VALUE arg) |
diff --git i/hash.c w/hash.c | |
index 007508a..6f39e47 100644 | |
--- i/hash.c | |
+++ w/hash.c | |
@@ -2402,6 +2402,28 @@ rb_hash_flatten(int argc, VALUE *argv, VALUE hash) | |
return ary; | |
} | |
+static int | |
+hash_comprised_i(VALUE key, VALUE value, VALUE arg) |
#!/usr/bin/env bash | |
main() { | |
if [ ! -p .test-commands ]; then | |
mkfifo .test-commands | |
fi | |
while true; do | |
cmd=$(cat .test-commands) | |
if [[ $cmd == "" ]]; then |