Skip to content

Instantly share code, notes, and snippets.

View danielevans's full-sized avatar

Daniel Evans danielevans

  • Anfract
  • Portland, OR
View GitHub Profile
@danielevans
danielevans / 20180928035240_create_games.rb
Created June 20, 2020 21:54
Migration Example in Rails
class CreateGames < ActiveRecord::Migration[5.2]
def change
create_table :games do |t|
t.integer :player_count
t.integer :board_count
t.string :rotation
t.datetime :starts_at
t.string :commongame_reference
t.timestamps
0.2s info: Rackula::Command::Generate [oid=0x2ace6e6e1088] [pid=1051] [2020-06-03 07:44:04 +0000]
| Setting up container to serve site on port 38777...
--2020-06-03 07:44:05-- http://localhost:38777/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:38777... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: /index [following]
--2020-06-03 07:44:05-- http://localhost:38777/index
Reusing existing connection to localhost:38777.
HTTP request sent, awaiting response... Markly::Error: could not get string content
@danielevans
danielevans / FancyMethod.sh
Last active January 31, 2019 22:47
Examples of how to search for source code using the unix tools find, grep and xargs
# This is a fancier and more reliable method, it only searches .js and .ts files, supports files and directories with spaces in the name
# but is more complicated to remember and type.... In other words I'm lazy, this is more work that most of the time isn't needed
find lib node_modules \( -iname "*.ts" -o -iname "*.js" \) -type f -print0 | xargs -0 grep 'my_method_name'
@danielevans
danielevans / minecraft-log.txt
Created November 27, 2018 23:31
RFTools builder bug recreation log
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128M; support was removed in 8.0
[16:26:57] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[16:26:57] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[16:26:57] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[16:26:57] [main/INFO] [FML]: Forge Mod Loader version 14.23.5.2772 for Minecraft 1.12.2 loading
[16:26:57] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_131, running on Mac OS X:x86_64:10.14, installed at /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
[16:26:58] [main/ERROR] [FML]: Apache Maven library folder was not in the format expected. Using default libraries directory.
[16:26:58] [main/ERROR] [FML]: Full: /Users/gate/Library/Application Support/MCUpdater/instances/test/libraries/org/apache/maven/3.5.3/maven-artif
@danielevans
danielevans / benchmark.rb
Last active March 8, 2017 19:11
Speed of delegation in ruby
require "active_support/core_ext/module"
require 'benchmark'
class Test
def initialize
@time = Time.now
end
delegate :to_i, to: :@time, prefix: :ar
require 'bridge'
SAYC_2_1.define do
# opening: true implies requirement that history contains only pass bids
convention :strong_2_club do
opening true
long_points minimum: 22
balanced true
bid level: 2, strain: Bridge::Strain::Club
end
# user system total real
# case 0.050000 0.000000 0.050000 ( 0.059868)
# if 0.090000 0.000000 0.090000 ( 0.091604)
# hash 0.070000 0.000000 0.070000 ( 0.081646)
# bad hash 0.690000 0.020000 0.710000 ( 0.709891)
require 'benchmark'
@danielevans
danielevans / gist:cb82c4ca5d45fd55fb091a9d45458ee6
Created May 12, 2016 23:15 — forked from eduardocardoso/gist:82a629882ddb02ab3677
Script to delete exited containers and untagged/unused images from docker
#!/bin/bash
set -o errexit
echo "Removing exited docker containers..."
docker ps -a -f status=exited -q | xargs -r docker rm -v
echo "Removing dangling images..."
docker images --no-trunc -q -f dangling=true | xargs -r docker rmi
# /Users/example/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/persistence.rb:185:in `destroy!'
# /Users/example/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/associations/has_many_association.rb:171:in `each'
# /Users/example/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/associations/has_many_association.rb:171:in `delete_records'
# /Users/example/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/associations/collection_association.rb:525:in `remove_records'
# /Users/example/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/associations/collection_association.rb:518:in `block in delete_or_destroy'
# /Users/example/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/associations/collection_association.rb:183:in `block in transaction'
# /Users/example/app/vendor/bundle/ruby/2.2.0/gems/test_after_commit-0.4.2/lib/test_after_commit.rb:27:in `block in transaction_with_transaction
@danielevans
danielevans / capybara.rb
Created February 26, 2016 06:04
capybara configuration
require 'capybara'
require 'capybara/dsl'
require 'capybara/poltergeist'
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, :js_errors => false)
end
Capybara.run_server = false
driver = :poltergeist