Skip to content

Instantly share code, notes, and snippets.

@redconfetti
redconfetti / test.md
Last active August 5, 2021 17:10
Markdown Example: HTML + Razor

Markdown Example

This is an example of a Markdown document that provides HTML with [Razor syntax] included, used in ASP.NET Core.

Example 1

This uses 'cshtml' as the language label.

@redconfetti
redconfetti / rust-cheatsheet.md
Last active January 19, 2021 15:28
Rust Cheatsheet
@redconfetti
redconfetti / template.rb
Last active December 20, 2020 17:03
Rails Application Template
# Use this template by running:
#
# $ rails new my_application --api --webpack=vue -m https://gist.githubusercontent.com/redconfetti/011aac614ebe3bd7d798b431fe789f5a/raw/6b917017d2f0ede9f183107f6c9db8cf821a59b3/template.rb
#
# Configure Rspec
puts "-- Configuring Rspec --"
gem_group :development, :test do
gem "rspec-rails"
end
@redconfetti
redconfetti / keybase.md
Created April 3, 2020 13:15
keybase.md

Keybase proof

I hereby claim:

  • I am redconfetti on github.
  • I am redconfetti (https://keybase.io/redconfetti) on keybase.
  • I have a public key ASAzmSErVw9jGPNYkpArJ0XNRecBxcnAxmPoQ6V42oM7Ago

To claim this, I am signing this object:

[
{
"google_experiment_mod3": "367",
"numbered": "true",
"google_experiment_mod": "42",
"size": "42",
"titled": "true",
"background": "#000",
"google_experiment_mod2": "942",
"options": "{\"charts\":{\"cards\":\"Untitled Chart\"},\"chosen\":\"cards\"}",
@redconfetti
redconfetti / main.rb
Created August 31, 2018 03:27
Enumerable.find - Hash and Key and Value Match
# It does work
my_hash = {a: 1, b: 2, c: 3, d: 4, e: 5}
my_hash.find {|k,v| puts "k:#{k},v:#{v}"; v == 3}
# Output:
# k:a,v:1
# k:b,v:2
# k:c,v:3
# => [:c, 3]
@redconfetti
redconfetti / constants-not-overridden.rb
Last active March 18, 2016 23:47
Constants in super classes not overridden by child classes
# It appears that a base class method refers to the constant value in that method
# instead of the constant value declared in child classes.
# You have to use a method to provide the expected behavior.
class BaseClass
COLUMNS = []
def self.shared_processor
child_processor(COLUMNS + ['column1'])
end
@redconfetti
redconfetti / super-class-method.rb
Last active March 18, 2016 19:45
Using super with class and instance methods
# Testing to see how 'super' method works with class and instance methods
# when passing pre-declared variables into the methods where I am expecting them to be modified
# Results noted provided by jruby-1.7.19
class SuperClass
def self.add_something(somehash)
somehash['something'] += 1
end
def add_something(somehash)
somehash['something'] += 5
@redconfetti
redconfetti / powerball.rb
Created March 5, 2016 05:25
Powerball Numbers
picks = []
balls = (1..69).to_a
5.times do
picks << balls.sample
end
powerball = (1..26).to_a.sample
puts "picks: #{picks.join(', ')} - powerball: #{powerball}"[
@redconfetti
redconfetti / main.yml
Created March 4, 2016 04:04
Ansible - Remote User Config
# /ansible/roles/remote-user/tasks/main.yml
#
---
- name: Test Default SSH port
local_action: wait_for port=22 timeout=5 host={{inventory_hostname}}
register: default_ssh
ignore_errors: true
- name: set ansible_ssh_port to default
set_fact: ansible_ssh_port=22