Skip to content

Instantly share code, notes, and snippets.

@jonahbron
jonahbron / sshs.sh
Last active January 18, 2023 19:48
Wrapper for ssh that allows you to automatically source your own .bashrc when logging-in to another computer. Place in your .bashrc file to use.
# Wrapper for ssh to automatically source bash config file on remote machine.
# Sources ~/.bashrc_remote
#
# author Jonah Dahlquist
# license CC0
sshs() {
ssh ${*:1} "cat > /tmp/.bashrc_temp" < ~/.bashrc_remote
ssh -t ${*:1} "bash --rcfile /tmp/.bashrc_temp ; rm /tmp/.bashrc_temp"
}
@jonahbron
jonahbron / install.sh
Last active October 31, 2020 16:30
Install AVR Rust and Compile Blink
git clone git@github.com:avr-rust/rust.git avr-rust
cd avr-rust
git checkout avr-support # 8405b30 at time of writing
cp config.toml.example config.toml
# Manually uncomment experimental-targets setting in config.toml
./x.py build
rustup toolchain link avr $(realpath $(find build -name 'stage2'))
cd ../../
@jonahbron
jonahbron / error
Created April 6, 2020 16:47
could not compile core
$ cargo +avr xbuild --target avr-unknown-unknown --verbose
WARNING: There is no root package to read the cargo-xbuild config from.
+ "rustc" "--print" "sysroot"
+ "rustc" "--print" "target-list"
+ "/home/jonah/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo" "rustc" "-p" "alloc" "--release" "--manifest-path" "/tmp/xargo.enQPopALFvIP/Cargo.toml" "--target" "avr-unknown-unknown" "-v" "--" "-Z" "force-unstable-if-unmarked"
Updating crates.io index
Downloaded compiler_builtins v0.1.26
Downloaded 1 crate (134.9 KB) in 0.78s
Compiling core v0.0.0 (/run/media/jonah/data/Projects/avr-rust/src/libcore)
Compiling compiler_builtins v0.1.26

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@jonahbron
jonahbron / FirebaseListAdapter.java
Created November 28, 2016 15:50
GeofireListAdapter
import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.google.firebase.database.ChildEventListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
#!/bin/bash
URL="page to watch"
PATTERN="pattern in page to watch"
get_page() {
curl "$URL" 2> /dev/null | grep -C 3 "$PATTERN"
}
NEW=$(get_page)
@jonahbron
jonahbron / punch.sh
Created December 18, 2013 00:27
Create a new, empty file if it does not exist. Creates parent directories if necessary.
# Create a new, empty file if it does not exist. Creates parent directories if necessary.
#
# author Jonah Dahlquist
# license CC0
punch() {
mkdir -p $(dirname $1)
touch $1
}
@jonahbron
jonahbron / have_friendly_id.rb
Last active December 28, 2015 09:19
Friendly_Id Shoulda Matcher.
# Copyright 2013 Jonah Dahlquist
# Creative Commons Attribution 3.0
#
# Installation:
# Add to your spec_helper.rb file:
# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# Add this file to spec/support/matchers/
#
# Usage:
# it { should have_friendly_id :title }
@jonahbron
jonahbron / fix_vagrant_boxes.sh
Created October 18, 2013 19:11
Upgrade Vagrant Boxes to 1.1
#!/bin/bash
provider=virtualbox
# Loop over boxes
for box in ~/.vagrant.d/boxes/*; do
# Create provider directory to contain files
mkdir $box/$provider/
@jonahbron
jonahbron / parchive.sh
Created May 24, 2013 22:47
Compress and archive project directory, with tab completion.
# Compress and archive project directory. Only deletes project directory if compression is successful.
#
# author Jonah Dahlquist
# license CC0
export PROJECTS_PATH=~/Projects
parchive() {
local project=$1
local year=`date +%Y`