Skip to content

Instantly share code, notes, and snippets.

@taboularasa
taboularasa / using apt-key add
Last active October 12, 2021 20:27
alternative to `apt-key add` for installing Debian packages
curl -sLS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install --no-install-recommends yarn
@taboularasa
taboularasa / caesar.rb
Created May 4, 2021 02:32
implement caesar cipher
def transpose(message, mapping)
message.chars.map {|e| mapping[e]}.join
end
puts "encode or decode?"
selected_action = gets.chomp
puts "what is the key?"
key = gets.chomp
puts "what is your message?"
message = gets.chomp
# Although our analytics team produces a styling algorithm
# it can't always capture everything a customer has requested.
# For example, a customer might write in their note to the stylist
# "Please no pink!!!". The algorithm can't always tell that,
# so it might suggest pink clothes for the customer.
#
# Suppose the stylist has the ability to manually filter out
# attributes the customer wants to avoid. What we'd like
# you to do is, given a list of items, and a list of
@taboularasa
taboularasa / keybase.md
Created August 24, 2016 17:36
keybase.md

Keybase proof

I hereby claim:

  • I am taboularasa on github.
  • I am davidelliott (https://keybase.io/davidelliott) on keybase.
  • I have a public key whose fingerprint is 7948 9BB4 CE88 AFE3 F563 501A BC46 D821 0F21 0480

To claim this, I am signing this object:

@taboularasa
taboularasa / flatten.rb
Created June 25, 2016 07:48
flatten an Array
require 'minitest/autorun'
##
# Implement flatten
#
# ruby -Ilib:test flatten.rb
def flatten(accumulator, element)
if element.is_a? Array
element.each {|e| flatten(accumulator, e)}
@taboularasa
taboularasa / .laptop.local
Created October 12, 2015 03:38
after laptop
#!/bin/sh
brew_tap 'caskroom/cask'
brew_install_or_upgrade 'brew-cask'
brew cask install google-chrome
sudo mv /opt/homebrew-cask/Caskroom/google-chrome/latest/Google\ Chrome.app /Applications
brew cask install chromium
brew cask install firefox
@taboularasa
taboularasa / a_user.rb
Last active August 29, 2015 14:26
Class Extraction Example
class User
def id
...
end
def name
...
end
def age
@taboularasa
taboularasa / gist:dcbf95daf2c61c38b607
Last active August 29, 2015 14:25
cascading selects in angular
<div ng-controller="TeacherReportsController">
<select ng-options="element.label for element in model" ng-model="firstOption"></select>
<select ng-options="child.label for child in firstOption.children" ng-model="secondOption"></select>
<select ng-options="child.label for child in secondOption.children" ng-model="thirdOption"></select>
{{thirdOption.data}}
</div>
layout title
post
Validating acyclic graphs

Alexis King and I were building an inventory management system for a Widget factory. In the warehouse they have a variety of containers that can hold either widgets or other containers. We needed to provide an inventory management system for the warehouse manager to keep track of the whereabouts of each container and widget. Here's how it needed to work:

  1. Manager logs into the inventory management system
  2. Manager navigates to the show view for an Inventory Location (i.e. a warehouse)
  3. Manager clicks on manage containers
@taboularasa
taboularasa / gist:69cc9f132642541155cb
Created September 23, 2014 19:51
Feature examples
Feature: Customer account
Scenario: viewing account information
Given I am a logged in customer
And I am viewing my dashboard
When I click the ACCOUNT link in the navigation
Then I should see a form with my account information filled in
Scenario: editing account information
Given I am a logged in customer
And I am viewing my dashboard