Skip to content

Instantly share code, notes, and snippets.

View revans's full-sized avatar
🤠
Building Businesses

Robert Evans revans

🤠
Building Businesses
View GitHub Profile
@revans
revans / example.rb
Last active November 18, 2022 14:41
# Instance Variable that is undefined
@person&.name # => nil
# Method that returns nil
def person; nil; end
person&.name # => nil
# local variable that is undefined - this is the one I am curious about since it "seems" to break convention
adult&.name # => undefined local variable exception raised
@revans
revans / gist:d7c240dfc3a8e79a76dce47842927784
Created May 14, 2021 00:38 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
file -bI INPUT_FILENAME | cut -d ';' -f 2 | cut -d '=' -f 2 | xargs -I % sh -c 'iconv -f % -t utf-8 INPUT_FILENAME >> OUTPUT_FILENAME'
#!/bin/bash
#
# Needs to be saved into your ~/bin directory
#
# Example: git dev my-feature-name
#
# set -e
git checkout -b dev/$1
# Copy this to your ~/.bash_profile
# for git
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
@revans
revans / demo.rb
Last active August 8, 2018 12:34
Using attr_reader with ||= and getting interesting results
# ruby 2.5.0p0 (2017-12-25 revision 61468)
class Demo
attr_reader :first_name
def initialize(first_name)
@first_name = first_name
end
def hi(myname = nil)
puts "Hello, #{first_name}"
@revans
revans / status_codes.rb
Last active January 19, 2018 23:27
Rails Status Codes
STATUS_CODES = {
100 => :continue,
101 => :switching_protocols,
102 => :processing,
200 => :ok,
201 => :created,
202 => :accepted,
203 => :non_authoritative_information,
204 => :no_content,
<form accept-charset="UTF-8" action="https://moonshine-app.herokuapp.com/f/abc" method="POST" id="contact-form">
<input type="hidden" name="utf-8" value="">
<input type="text" class="col-md-6 col-xs-12 name" name="name" placeholder="Name *" required="">
<input type="text" class="col-md-6 col-xs-12 Email" name="email" placeholder="Email *" required="">
<input type="text" class="col-md-12 col-xs-12 Subject" name="subject" placeholder="Subject">
<textarea type="text" class="col-md-12 col-xs-12 Message" name="body" placeholder="Message *" required=""></textarea>
<div class="cBtn col-xs-12">
<ul>
<!-- <li class="clear"><a href="#"><i class="fa fa-times"></i>clear form</a></li> -->
<li class="send"><a href="#" onclick="document.getElementById('contact-form').submit();"><i class="fa fa-share"></i>Send Message</a></li>
config.middleware.use RoutesReloader
@revans
revans / table_hack.rb
Created December 17, 2015 21:27
Fun little hack that allows you to use 1 model to access any table in the database.
class Standin < ApplicationRecord
def self.set_table_name=(name)
self.table_name = name
end
def self.get_table_name
self.table_name
end
end