Skip to content

Instantly share code, notes, and snippets.

View johana-star's full-sized avatar
🕶️

Johana Star johana-star

🕶️
View GitHub Profile
@johana-star
johana-star / generate.sh
Created May 7, 2015 04:48
The beginning of a site generator using Pandoc.
#!/bin/bash
for file in `ls ./posts/*.markdown`
do
shortname=`expr $file : '.*[[:digit:]]-\(.*\).markdown' `
pandoc --smart \
--from=markdown+yaml_metadata_block \
$file \
--output ./site/$shortname .html
done
@johana-star
johana-star / status.md
Created May 6, 2015 16:22
Status Report

I feel like I'm grinding at work, but work is easy. The expectations are reasonable, but every bug takes longer than I want to fix because the code is a tangled mess and it's no one's responsibility to clean up or collective confusion.

I don't understand how this app will get better when we're not talking as an organization about what makes it bad, or worse, just ignoring the heck out of why it's hard to change and hard to maintain.

And then I realize that part of why it feels like I'm grinding is that while I now have a bit of a life, I'm giving most of my mental energy to my employer. Like last night around eight, I sat on my couch and considered extracting a repetitious bit of code. I ran specs on the models it was repeated in, tried deleting it to find failing specs…

And this morning I realize that my job is to fix bugs on my little corner of the app, not make it prettier throughout, and that it certainly isn't to fix the app at eight at night. I made a few small PRs to the [Ruby Style Guide](https://g

The syntax of bash more complicated than a one-liner still trips me up.

Yesterday at work I wanted to write a short script to read each line in a file, and use Rubocop to auto-correct the issue type listed on that line. I googled how to iterate over each line of a file and got the following example code:

while read p; do
  echo $p
done <peptides.txt

Ingredients:

  • two big carrots
  • one pound of purple potatoes
  • five stalks of celery
  • half a large sweet onion
  • two or three sprigs thyme
  • two sprigs rosemary
  • an eighth cup kosher salt
  • olive oil
require "active_support/all"
def format_date_range(from, to = false)
to = from if to.blank?
return '' if from.nil? && to.nil?
from, to = [to, from].sort
if from == to
month_day_year(from)
elsif from.year == to.year
@johana-star
johana-star / partials.erb
Last active August 29, 2015 14:02
Showing partials with locals in Sinatra
<%# BEFORE %>
<%# views/twiends_index.erb %>
<div class="twiends">
<%= @twiends.count %>
<table>
<tbody>
<% @twiends.each do |friend| %>
<tr class="<%= ("location-enabled" if friend[:geo_enabled]) %>">
<td>
@johana-star
johana-star / base60.rb
Last active October 25, 2022 06:31
A Base60 encoder/decoder for creating human-readable shorturls.
module Base60
# See link below for specifications of this Base60.
# http://tantek.pbworks.com/w/page/19402946/NewBase60
# Based off of the Base62 gem (link below)
# https://github.com/jtzemp/base62/blob/master/lib/base62.rb
PRIMITIVES = ('0'..'9').to_a + ('A'..'H').to_a + ('J'..'N').to_a +
('P'..'Z').to_a + ["_"] + ('a'..'k').to_a + ('m'..'z').to_a
class << self
@johana-star
johana-star / .zshrc
Created April 4, 2014 19:18
~/.zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Example aliases
@johana-star
johana-star / craigslist_scraper.rb
Created December 10, 2013 22:41
Scrape location data out of Craigslist postings with Nokogiri.
require "nokogiri"; require "open-uri"
doc = Nokogiri::XML open 'http://sfbay.craigslist.org/search/apa/sfc?bedrooms=1&catAbb=apa&maxAsk=2000&format=rss'
urls = doc.xpath("//rdf:li").map { |entry| entry.values.first }
page = Nokogiri::HTML open urls.first
# This page contains a div with an id of 'map' which has two attributes:
# 'data-latitude' and 'data-longitude'. How do I get their values?
# Something like: (???)
page.css("div#map").???
@johana-star
johana-star / Playing with APIs
Last active December 28, 2015 03:49
Playing with APIs
Application Programming Interfaces!