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
allolex / install_asdf_rust_jetbrains_clion_2022_in_2023.md
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
allolex / pr.md
Created May 9, 2016 16:37 — forked from piscisaureus/pr.md
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 = git@github.com:joyent/node.git

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
allolex / mobile_dev_choices.md
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
end
require_relative 'talkative'
class Vehicle
attr_accessor :engine, :tires
end
class Car < Vehicle
def initialize
@tires = 4
end
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
else
number.concat "2"
module AlphabetTesters
def self.a? letter
letter.downcase == "a"
end
def self.b? letter
letter.downcase == "b"
end
def a? letter