This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " Inline ruby interpretation, inspired by RubyTapas. | |
| " | |
| " Example output when run over the top line: | |
| " | |
| " 3.times { |num| puts num } | |
| " # => 0 | |
| " # => 1 | |
| " # => 2 | |
| " | |
| vmap <leader>r :!tee >(cat) \| ruby \| sed 's/^/\\# \=> /'<cr> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create or edit /etc/fstab/ to contain this: | |
| LABEL=VOLUME_NAME none ntfs rw,auto,nobrowse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| for i in $(find $PWD -maxdepth 1 -type d); do | |
| cd $i | |
| if [ -d .git ]; then | |
| remotes=$(git remote -v) | |
| if [[ "$remotes" =~ origin.git@github.com:myorg ]]; then | |
| git remote set-url origin git@github.com:myneworg/$(basename `git rev-parse --show-toplevel`) | |
| fi | |
| fi | |
| cd .. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def x(one: 1, two: 2) | |
| local_variables.each_with_object({}) do |var, memo| memo[var] = eval(var.to_s) end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a place where you can put code that should be executed once, | |
| # and accessed by several different threads. When it is called, it will | |
| # block the thread until the calculation has been completed, and memoize it. | |
| # | |
| # This means all threads that call the same method will wait for the same result, | |
| # that is only carried out once. Think of it as a traffic light; cars arrive at the | |
| # red light at different times, wait, and all take off together once it turns green. | |
| class CrossThreadMemoizer | |
| def initialize(callable) | |
| @callable = callable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| table { | |
| padding: 0; | |
| border-collapse: collapse; | |
| } | |
| table tr { | |
| border-top: 1px solid #cccccc; | |
| background-color: white; | |
| margin: 0; | |
| padding: 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Rakefile | |
| namespace :db do | |
| desc "Run migrations" | |
| task :migrate, [:version] do |t, args| | |
| require "sequel" | |
| Sequel.extension :migration | |
| db = Sequel.connect(ENV.fetch("DATABASE_URL")) | |
| if args[:version] | |
| puts "Migrating to version #{args[:version]}" | |
| Sequel::Migrator.run(db, "db/migrations", target: args[:version].to_i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Reset | |
| Color_Off='\[\e[0m\]' | |
| # Regular Colors | |
| Black='\[\e[0;30m\]' | |
| Red='\[\e[0;31m\]' | |
| Green='\[\e[0;32m\]' | |
| Yellow='\[\e[0;33m\]' | |
| Blue='\[\e[0;34m\]' | |
| Purple='\[\e[0;35m\]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.ArrayList; | |
| import java.util.Arrays; | |
| public class Primes { | |
| public static void main(String[] args) { | |
| int limit = 1000; | |
| // Calculate primes under limit and measure the time it took | |
| long startTime = System.currentTimeMillis(); | |
| ArrayList<Integer> answer = primes(limit); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Monkeypatch to remove tasks | |
| module Rake | |
| def self.remove_task(task_name) | |
| Rake.application.instance_variable_get('@tasks').delete(task_name.to_s) | |
| end | |
| end | |
| # Example: disable all of the tasks in the db namespace | |
| namespace :db do |ns| | |
| ns.tasks.each do |task| |