Skip to content

Instantly share code, notes, and snippets.

Sam Schlinkert sts10

Block or report user

Report or block sts10

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sts10
sts10 / write_to.rs
Last active May 9, 2019
Rust script defining function that can write either to Terminal or a file
View write_to.rs
use std::fs::File;
use std::io::{self, Write};
#[derive(Debug)]
pub enum Destination<'a> {
Terminal,
File(&'a std::fs::File),
}
fn main() {
print_report(Destination::Terminal).expect("Error printing report to terminal");
@sts10
sts10 / playing-with-digits.rs
Created Apr 11, 2019
Playing with Digits kata
View playing-with-digits.rs
// https://www.codewars.com/kata/playing-with-digits/train/rust
// status: Getting a multiply overflow werror when I "Attempt"
fn dig_pow(n: i64, p: i32) -> i64 {
let digits: Vec<_> = n.to_string().chars().map(|d| d.to_digit(10).unwrap()).collect();
let mut sum: u64 = 0;
let mut i: u32 = 0;
for digit in digits {
@sts10
sts10 / alacritty.yml
Last active May 14, 2019
My Alacritty config yml for MacOS (compliant with v 0.3.2)
View alacritty.yml
# Configuration for Alacritty, the GPU enhanced terminal emulator
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty it self.
env:
# TERM env customization.
#
# If this property is not set, alacritty will set it to xterm-256color.
#
@sts10
sts10 / day04.rs
Created Dec 5, 2018
my not-working day 4 part 1 solution (Advent of Code 2018)
View day04.rs
use std::collections::HashMap;
use std::fs::File;
use std::io;
use std::io::BufRead;
use std::io::BufReader;
use std::str::FromStr;
fn main() {
let mut events_vec: Vec<String> = read_by_line("inputs/day04-test.txt").unwrap();
@sts10
sts10 / pyenv.markdown
Last active Jul 11, 2019
Installing and setting up a decent Python configuration in MacOS
View pyenv.markdown

Installing and setting up a decent Python configuration in MacOS 10.11

Before I took these steps, I ran brew uninstall python in an attempt to clear out a different Python installation. I also had to clear out some stuff in my .bash_profile.

  1. Install Pyenv via Homebrew: brew update && brew install pyenv
  2. Add stuff to .bash_profile: echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
  3. Restart terminal.
  4. Maybe install dependencies? (You may be good to go already.)
  5. pyenv install --list and pick new-ish-but-stable versions of python2 and python3 to install. For example: pyenv install 3.7.0 2.7.15
  6. You can set version 3 as the global, with 2 as fall-back: pyenv global 3.7.0 2.7.15. You can also set your system's Python as a secondary fallback by running pyenv global 3.7.0 2.7.15 system.
@sts10
sts10 / masto_following_updater.rb
Last active Oct 25, 2018
A Ruby script that's (trying to) find moved accounts for you to follow
View masto_following_updater.rb
require 'mastodon'
require 'csv'
system("clear")
puts "Welcome to the Mastodon Following Updater!"
puts "\n"
puts "First, enter the URL of your home instance. For example, https://mastodon.social or https://octodon.social"
base_url = gets.chomp
system("clear")
@sts10
sts10 / yubikey-gpg-question.markdown
Last active Feb 8, 2018
Question about OpenPGP and YubiKey
View yubikey-gpg-question.markdown

Below is a step-by-step guide to test whether I could get a secret PGP key off of my YubiKey.

  1. On Computer 1, generate a GPG key pair.
  2. More your secret key to a YubiKey, following the instructions on this wedpage under "Generating the key on your local system"
  3. On computer 2, import the public key of the key pair.
  4. Still on computer 2, insert your YubiKey. Then create a stub for the secret key by running gpg --card-status source
  5. Unplug YubiKey.
  6. On computer 2, run gpg --export-secret-keys -a KEYID > secret.asc, filling in the KEYID with the key id.
  7. A private key is now in the file secret.asc
@sts10
sts10 / day03.rs
Last active Dec 4, 2017 — forked from anonymous/playground.rs
Advent of Code 2017 Day 3, part 1
View day03.rs
fn main() {
println!("Ring number for 12 is {}", get_ring_number(12));
println!("distance to closest railroad for 12 is {}", find_distance_to_closest_railroad(12));
println!("total steps for 12 is {}", find_distance_to_closest_railroad(12) + get_ring_number(12));
println!("total steps for 23 is {}", find_distance_to_closest_railroad(23) + get_ring_number(23));
println!("total steps for 1024 is {}", find_distance_to_closest_railroad(1024) + get_ring_number(1024));
println!("total steps for 347991 is {}", find_distance_to_closest_railroad(347991) + get_ring_number(347991));
}
@sts10
sts10 / masto-counter.rb
Last active Apr 6, 2017
Counts total users and number of instances, and displays the top 15 instances of the Mastodon network
View masto-counter.rb
require 'open-uri'
require 'nokogiri'
require 'json'
url = "https://instances.mastodon.xyz/instances.json"
# Or, if you saved down a local copy...
# url = "instances.json"
instance_json = Nokogiri::HTML(open(url))
View contact.md

Wire (see note below)

username: @sschlinkert

key fingerprint (iPhone):

aa 80 a4 d2 f3 8b 63 ff ea ff 16 86 bf 6d 29 06 
ad 39 bb 3e 11 7d 0a 56 e6 44 77 08 5a 80 b6 bb
You can’t perform that action at this time.