Skip to content

Instantly share code, notes, and snippets.

@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
@chetan
chetan / yardoc_cheatsheet.md
Last active April 16, 2024 23:49
YARD cheatsheet
@elderbas
elderbas / class_controller.ex
Last active April 5, 2024 03:35
Elixir — Inserting Multiple Changesets Into Database - create batch
def create_batch(conn, %{"people" => people_params}) do
changesets = Enum.map(people_params, fn class ->
Person.changeset(%Person{}, person)
end)
result = changesets
|> Enum.with_index()
|> Enum.reduce(Ecto.Multi.new(), fn ({changeset, index}, multi) ->
Ecto.Multi.insert(multi, Integer.to_string(index), changeset)
end)
@erichurst
erichurst / database.yml.example mysql2
Created May 9, 2011 02:58
Rails 3 database.yml examples
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@takeit
takeit / INSTALL.md
Last active March 23, 2024 19:03
Write to NTFS on macOS Sierra (osxfuse + ntfs-3g)
  1. Install osxfuse:
brew cask install osxfuse
  1. Reboot your Mac.

  2. Install ntfs-3g:

@tkfu
tkfu / srd_5e_monsters.json
Last active March 23, 2024 15:45
A JSON file with all the D&D 5e SRD monster data
[
{
"name": "Aboleth",
"meta": "Large aberration, lawful evil",
"Armor Class": "17 (Natural Armor)",
"Hit Points": "135 (18d10 + 36)",
"Speed": "10 ft., swim 40 ft. ",
"STR": "21",
"STR_mod": "(+5)",
"DEX": "9",
@jamesgmarks
jamesgmarks / gist:56502e46e29a9576b0f5afea3a0f595c
Last active March 12, 2024 19:30
MySQL/MariaDB BIN_TO_UUID and UUID_TO_BIN Polyfill
DELIMITER //
CREATE FUNCTION BIN_TO_UUID(b BINARY(16))
RETURNS CHAR(36)
BEGIN
DECLARE hexStr CHAR(32);
SET hexStr = HEX(b);
RETURN LOWER(CONCAT(
SUBSTR(hexStr, 1, 8), '-',
SUBSTR(hexStr, 9, 4), '-',
@MaxLap
MaxLap / rubocop.rb
Last active March 12, 2024 17:15 — forked from skanev/rubocop.rb
A Rubocop wrapper that checks only added/modified code
#!/usr/bin/env ruby
# A sneaky wrapper around Rubocop that allows you to run it only against
# the recent changes, as opposed to the whole project. It lets you
# enforce the style guide for new/modified code only, as opposed to
# having to restyle everything or adding cops incrementally. It relies
# on git to figure out which files to check.
#
# Here are some options you can pass in addition to the ones in rubocop:
#
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)