Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am thomas-holmes on github.
  • I am tholmes (https://keybase.io/tholmes) on keybase.
  • I have a public key whose fingerprint is 4A0B 8FC7 6284 533D E475 DC1C 2C86 C918 7682 84CC

To claim this, I am signing this object:

class Company < ActiveRecord::Base
before_create :generate_api_token
attr_accessible :name, :owner, :owner_id
validates :name, presence: true, uniqueness: { case_sensitive: false }, :length => { :minimum => 5, :maximum => 40 }
validates :owner, presence: true
validates :owner_id, presence: true
@thomas-holmes
thomas-holmes / expose_current_running_example_as_spec.feature
Created August 14, 2013 03:34
Feature of expose_current_running_example_as
Feature: expose_current_running_example_as
Use `config.expose_current_running_example_as` to create a new example group
method that provides accessing to the currently running example
Scenario: Use expose_current_running_example_as to expose currently running example as current_example
Given a file named "expose_current_running_example_as_spec.rb" with:
"""ruby
RSpec.configure do |c|
c.expose_current_running_example_as :current_example

Hack on github.com with Kyle Neath

At GitHub, they've set out to GitHub be the best place to share code with friends, co-workers, classmates, and complete strangers.

Already, over three million people use GitHub to build amazing things together.

But that isn't enough. Everyone should enjoy the benefits of Git and everyone should Fork everything.

It turns out GitHub needs your help. You can be GitHub's partner in crime to help Kneath out.

@thomas-holmes
thomas-holmes / gist:6910192
Created October 9, 2013 23:15
AND combined selectors
I like the way control-p works except for how it treats spaces. I want control-p search style but where I can separate terms with spaces.
With control-p to find all views with vast in they name you would type something like 'viewcat'
I want to be able to type 'view cat'. I would like e results of that search string to be the intersected results of a control-p style search for each string separated by spaces. It would match 'views/cat' and 'cat/view'.
Mostly this is a habit driven request but sometimes I really do want to do a combined search like that.
Sorry if I botched the grammar a bit, the gist editor is pretty bad on mobile.
@thomas-holmes
thomas-holmes / Foo.java
Last active June 29, 2016 14:57
covariance fail
// Assume Cat and Dog are descendants of Animal. Yes I know this is a garbage example of inheritance
public class Foo {
public void failAppend(List<Cat> catList) {
Cat cat = new Cat();
Dog dog = new Dog();
Aniaml animal = new Cat();
catList.append(cat); // Obviously can do this
catList.append(dog); // Obviously can't do this
@thomas-holmes
thomas-holmes / broken_lock_texture.go
Last active November 26, 2017 06:10
Example of go-sdl SDL_TextureLock bug
package main
import (
"github.com/veandco/go-sdl2/sdl"
)
func main() {
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err)
}
@thomas-holmes
thomas-holmes / cloc-aggregate.txt
Last active March 8, 2018 19:11
example cloc output
keipra@k1 ~/g/s/g/t/delivery-rl (master)> cloc . --exclude-dir=vendor,.vscode
60 text files.
60 unique files.
4 files ignored.
github.com/AlDanial/cloc v 1.74 T=0.06 s (947.4 files/s, 98349.4 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Go 46 977 117 4505

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
C:\Users\Thomas\Documents>gcc foo.c
foo.c:2:1: warning: return type defaults to 'int' [-Wimplicit-int]
main(t,_,a)
^~~~
foo.c: In function 'main':
foo.c:2:1: warning: type of 't' defaults to 'int' [-Wimplicit-int]
foo.c:2:1: warning: type of '_' defaults to 'int' [-Wimplicit-int]
C:\Users\Thomas\Documents>./a.exe
'.' is not recognized as an internal or external command,