Skip to content

Instantly share code, notes, and snippets.

View allolex's full-sized avatar
Working from home

Damon Davison allolex

Working from home
View GitHub Profile
allolex /
Last active November 12, 2023 18:33
asdf, rust, and the JetBrains CLion IDE

asdf, rust, and JetBrains CLion IDE.

JetBrains has a new Rust IDE, but I don't want to pay for the license, so I am using a fallback version of CLion. That means my IDE is vintage 2022.

  1. Install rust using asdf in the usual way.
    • asdf install rust latest
    • That's currently 1.7.3 for me right now.
  2. After you have done that, set .tool-versions with that version:
    • asdf local rust latest
  3. Install the rust standard library:
allolex /
Created May 9, 2016 16:37 — forked from piscisaureus/
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url =

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

allolex /
Created December 16, 2015 19:22
Mobile development frameworks, write once and target many devices

Inverse sorting of a hash by value

  • Explain the Hash[] syntax.
  • Demonstrate #sort_by.
  • Show how sorting hashes is not necessarily straightforward.

Let's create a hash and experiment with it.

h = { a: 10, b: 9, c: 8 }
class Table
# attr_reader :num_legs
# attr_writer :num_legs
attr_accessor :num_legs
def initialize(legs)
@tabletop = []
@num_legs = legs
require_relative 'talkative'
class Vehicle
attr_accessor :engine, :tires
class Car < Vehicle
def initialize
@tires = 4
def add_two(number = 0, *rest)
return nil unless number.respond_to? :+
# if number.respond_to? :+
if number.respond_to? :concat
puts "srsly?" if rest.size > 0
if number.respond_to? :push
number.push 2
number.concat "2"
module AlphabetTesters
def self.a? letter
letter.downcase == "a"
def self.b? letter
letter.downcase == "b"
def a? letter