Skip to content

Instantly share code, notes, and snippets.

@taboularasa
taboularasa / using apt-key add
Last active Oct 12, 2021
alternative to `apt-key add` for installing Debian packages
View using apt-key add
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
implement caesar cipher
View caesar.rb
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
View exercise.rb
# 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
View 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:

View flatten.rb
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)}
View .laptop.local
#!/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 Aug 29, 2015
Class Extraction Example
View a_user.rb
class User
def id
...
end
def name
...
end
def age
@taboularasa
taboularasa / gist:dcbf95daf2c61c38b607
Last active Aug 29, 2015
cascading selects in angular
View gist:dcbf95daf2c61c38b607
<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>
View gist:2d4fdaec2afc34d01eb8
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
View gist:69cc9f132642541155cb
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