Skip to content

Instantly share code, notes, and snippets.

@kluzny
kluzny / matchers.rb
Last active July 31, 2024 17:35
Some custom rspec matchers for inspecting json responses
require 'rspec/expectations'
# expect(response).to be_json_success
RSpec::Matchers.define :be_json_success do |_expected|
match do |actual|
actual.status == 200 && actual.content_type.match("application/json")
end
failure_message do |actual|
"expected status: 200, content_type: 'application/json', got status: #{actual.status}, content_type: '#{actual.content_type}'"
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@gonejack
gonejack / mapper-0.74.map
Last active February 26, 2024 11:19
Colemak keymap for DOSBox, put this file to %LOCALAPPDATA%\DOSBox
hand_shutdown "key 290 mod1"
hand_capmouse "key 291 mod1"
hand_fullscr "key 13 mod2"
hand_pause "key 19 mod2"
hand_mapper "key 282 mod1"
hand_speedlock "key 293 mod2"
hand_recwave "key 287 mod1"
hand_caprawmidi "key 289 mod1 mod2"
hand_scrshot "key 286 mod1"
hand_video "key 286 mod1 mod2"
@kristianmandrup
kristianmandrup / Converting libraries to Ember CLI addons.md
Last active April 21, 2023 17:14
Guide to Developing Addons and Blueprints for Ember CLI

Converting libraries to Ember CLI addons

In this guide we will cover two main cases:

  • Ember specific library
  • vendor library

Ember library

The Ember library will assume that Ember has already ben loaded (higher in the loading order) and thus will assume it has access to the Ember API.

@lassebunk
lassebunk / sunspot_tasks.rake
Last active July 24, 2020 04:10
Reindex Sunspot Solr gracefully
# This task can be used reindex Solr without dropping your index first.
# This is ideal for production environments where a live, working index is critical.
#
# Put this in lib/tasks/sunspot_tasks.rake
namespace :sunspot do
task reindex_gracefully: :environment do
Dir.glob(Rails.root.join('app/models/**/*.rb')).each { |path| require path }
sunspot_models = Sunspot.searchable
@areina
areina / emacs-email-setup.md
Created October 12, 2012 15:00
Manage your email in emacs with mu4e

Manage your gmail account in emacs with mu4e

There're a lot of combinations to manage your email with emacs, but this works for me. I've a backup and I can manage my daily email.

The stack:

  • emacs
  • offlineimap
  • mu
  • mu4e