Skip to content

Instantly share code, notes, and snippets.

@stopdropandrew
stopdropandrew / ba.sh
Last active May 18, 2020 00:05 — forked from bvolpato/ba.sh
Install Chrome Driver with Xvfb (Ubuntu Server)
#!/bin/bash
# prereqs
sudo apt-get install unzip
# Chrome Repo
sudo apt-get install fonts-liberation xdg-utils libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
@stopdropandrew
stopdropandrew / adbquery.rb
Created November 19, 2019 00:52
convert adb content query output to json
#!/usr/bin/env ruby
require 'json'
results = `adb shell content query #{ARGV.join(' ')}`
lines = results.split("\n")
rows = lines.map do |line|
match = line.match(/Row: \d+ (.*)/)
next unless match
export function initialize(/* appInstance */) {
// appInstance.inject('route', 'foo', 'service:foo');
}
export default {
initialize
};
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle gist'
});
@stopdropandrew
stopdropandrew / datecheckerbench.rb
Last active September 10, 2016 21:47
more optimization!
Benchmark.ips do |x|
strings = ['android', '1002,60009,30012,60004,20023,10005,10011,50003,10012,50004,10005,30013,60007,10006', '4068B063-0CDF-4579-B4E9-15298ECF9929', 'android', '1002,60009,30012,60004,20023,10005,10011,50003,10012,50004,10005,30013,60007,10006', '4068B063-0CDF-4579-B4E9-15298ECF9929', 'android', '1002,60009,30012,60004,20023,10005,10011,50003,10012,50004,10005,30013,60007,10006', '4068B063-0CDF-4579-B4E9-15298ECF9929']
times = ['2016-08-01 13:00:01+0000', '2016-08-01T13:00:01+0000', '2015-09-27T16:36:45.966+0000']
10.times do
times += strings
end
pt = times.map { |t| Time.parse(t) rescue nil }
x.report("match then build w/ iso") do
times.each_with_index do |time, i|
require 'csv'
coach_years=CSV.read('coaches.csv')[1..-1]
def parse_coach_year(coach_year)
start_year, end_year_suffix = coach_year[0].split('-')
end_year_prefix = start_year < '2000' ? '19' : '20'
end_year = "#{end_year_prefix}#{end_year_suffix}"
return coach_year[1], start_year.to_i, end_year.to_i
end
@stopdropandrew
stopdropandrew / gist:3707236
Created September 12, 2012 15:04
linecache19 & bundler
Installing ruby_core_source (0.1.5)
Installing linecache19 (0.5.11) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for vm_core.h... no
checking for vm_core.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
@stopdropandrew
stopdropandrew / post-checkout
Created May 18, 2012 23:32
post-checkout and post-merge
#!/bin/bash
# Check if any submodule has been updated in HEAD after a merge (or
# pull) or a branch checkout. If so, ask if user wants to run
# git-submodule update.
# --Chaitanya Gupta
SCRIPT_NAME=$(basename "$0")
if [[ "$SCRIPT_NAME" = "post-checkout" && "$1" = "$2" || "$3" = "0" ]]; then
alias oops="rfind breakpoint; rfind debugger"
function rfindhelper () {
find $1 -name '*.rb' -o -name '*.rhtml' -o -name '*.erb' -o -name '*.rjs' -o -name '*.builder' -o -name '*.js' | xargs grep -i "$2"
}
function rfind () {
rfindhelper "app config test lib" "$*"
}
function rfindrails () {
rfindhelper "vendor/rails" "$*"