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 ugly... What's a better way? | |
begin | |
@beans = beans.find(params[:id]) | |
begin | |
@beans.destroy | |
rescue ActiveRecord::StaleObjectError => exception | |
end | |
rescue ActiveRecord::RecordNotFound => exception | |
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
require 'ostruct' | |
# Given this array[hash[hash]] structure | |
a = [{"object" => {param1: true, param2: false}},{"object" => {param1: false, param2: true}}] | |
# I want to return: | |
=> [<OpenStruct param1=true, param2=false>, <OpenStruct param1=false, param2=true>] | |
# Current code: | |
a.map { |k| k.map { |k,v| OpenStruct.new v } } |
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
class Awesome | |
@@troll = "ME!" | |
end | |
module MyGem | |
module Namespace | |
def trolling | |
puts @@troll | |
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
/* | |
Scenario: App requests the user to provide accessors to an JSON object that they also provide. | |
e.g. User provides the following JSON object: | |
{ people: [ | |
{ firstName: "Bob", lastName: "Jones" }, | |
{ firstName: "Jane", lastName: "Jones" } | |
], numbers: [1, 2, 3] | |
} | |
The JSON object is saved to the 'data' variable by the app. |
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
// List of badly formatted emails | |
var _badEmails = ['bad@email', 'roar@me']; | |
var _validationMessage = 'Invalid emails: ' + badEmails.join(', '); | |
// _validationMessage should be: 'Invalid emails: bad@email, roar@me' | |
expect(_validationMessage).toBe('Invalid emails: ' + _badEmails.join(', ') | |
// However, the expect statement fails as validationMessage becomes: | |
'Invalid emails: bad@emails, roar@me, function () { |
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
1. Install Xcode, if you haven't already. | |
a. Once installed, run Xcode and accept the license agreement. | |
b. Go into Xcode Prefs (Cmd + ,), go to Downloads, and install "Command Line Tools for Xcode" (or something named similarily) | |
2. Install Homebrew (copy and paste the following into your terminal): | |
```bash | |
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" |
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
#!/usr/bin/env ruby | |
class String | |
# Give our output some colour option :D! | |
def black; "\033[30m#{self}\033[0m" end | |
def red; "\033[31m#{self}\033[0m" end | |
def green; "\033[32m#{self}\033[0m" end | |
def blue; "\033[34m#{self}\033[0m" end | |
def yellow; "\033[33m#{self}\033[0m" end | |
def magenta; "\033[35m#{self}\033[0m" 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
def method_missing symbol, *args | |
return symbol.id2name | |
end | |
def 🍴 😋=nil | |
@👅 ||= [] | |
@👅 << 😋 if 😋 | |
@👅 | |
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
1: LD vm/vm | |
vm/llvm/artifacts/disassembler.cpp.o: In function `rubinius::JITDisassembler::JITDisassembler(void*, unsigned long)': | |
/home/pyg/src/rubinius-3.19/vm/llvm/disassembler.cpp:34: undefined reference to `llvm::sys::getDefaultTargetTriple[abi:cxx11]()' | |
/home/pyg/src/rubinius-3.19/vm/llvm/disassembler.cpp:44: undefined reference to `llvm::TargetRegistry::lookupTarget(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)' | |
/home/pyg/src/rubinius-3.19/vm/llvm/disassembler.cpp:52: undefined reference to `llvm::sys::getHostCPUName[abi:cxx11]()' | |
/home/pyg/src/rubinius-3.19/vm/llvm/disassembler.cpp:57: undefined reference to `llvm::sys::getHostCPUName[abi:cxx11]()' | |
vm/llvm/artifacts/jit_context.cpp.o: In function `rubinius::Context::Context(rubinius::LLVMState*)': | |
/home/pyg/src/rubinius-3.19/vm/llvm/jit_context.cpp:114: undefined reference to `llvm::DataLayout::getStringRepresentation[abi:cxx11]() |
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
Mar 1 03:46:40 [267] command line: gem install sinatra | |
Mar 1 03:46:40 [267] node info: b0c4e5a8c4c9 #1 SMP Tue Nov 3 19:10:07 UTC 2015 | |
Mar 1 03:46:40 [267] process info: root rbx 267 3.15 2.2.2 2016-02-23 2016-02- 3.4 JIT | |
Mar 1 03:46:40 [267] <Fatal> The Rubinius process is aborting with signal: SIGSEGV | |
Mar 1 03:46:40 [267] <Fatal> --- begin system info --- | |
Mar 1 03:46:40 [267] <Fatal> node info: b0c4e5a8c4c9 #1 SMP Tue Nov 3 19:10:07 UTC 2015 | |
Mar 1 03:46:40 [267] <Fatal> --- end system info --- | |
Mar 1 03:46:40 [267] <Fatal> --- begin rubinius info --- | |
Mar 1 03:46:40 [267] <Fatal> process info: root rbx 267 3.15 2.2.2 2016-02-23 2016-02- 3.4 JIT | |
Mar 1 03:46:40 [267] <Fatal> --- end rubinius info --- |
OlderNewer