Skip to content

Instantly share code, notes, and snippets.

View MaxPleaner's full-sized avatar

Max Pleaner MaxPleaner

View GitHub Profile
@MaxPleaner
MaxPleaner / gist:aa692b23d3d5f4b3f53a7407b2ff2f40
Created August 30, 2016 17:27
cucumber lexicons - github projects which define steps for cucumber
https://github.com/makandra/cucumber_factory
Create records from Cucumber features without writing step definitions. http://makandra.com/
https://github.com/jayzes/cucumber-api-steps
Cucumber steps to easily test REST-based XML and JSON APIs
https://github.com/collectiveidea/json_spec
Easily handle JSON in RSpec and Cucumber http://rubygems.org/gems/json_spec
https://github.com/napcs/cucumber_watir
@MaxPleaner
MaxPleaner / aws_helpers.rb
Last active August 23, 2016 04:48
create public bucket on s3 with ruby
require 'aws-sdk'
require 'fog'
# --------------
# before running this, set the required environment variables:
# AWS_ACCESS_KEY_ID
# AWS_SECRET_ACCESS_KEY
# AWS_REGION
# --------------
@MaxPleaner
MaxPleaner / start_driver.rb
Last active August 9, 2016 06:39
download-capable firefox profile with selenium
# Create a firefox driver that can be passed to HeadlessBrowser.new
def start_driver
profile = Selenium::WebDriver::Firefox::Profile.new
profile["browser.download.folderList"] = 2 # This allows downloads to be sent to a custom location
profile["browser.download.manager.showWhenStarting"] = false
profile["browser.download.dir"] = `/home/max/Downloads` # download to this custom path
# FILES WILL NOT DOWNLOAD UNLESS THEIR MIME TYPE IS INCLUDED IN THIS LIST!
profile["browser.helperApps.neverAsk.saveToDisk"] = accepted_mime_types_for_download
@MaxPleaner
MaxPleaner / node-and-npm-in-30-seconds.sh
Created August 6, 2016 20:43 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@MaxPleaner
MaxPleaner / main.js
Last active April 20, 2017 19:03
meteor geolocation/maps excerpt (part of https://medium.com/p/adf3c3d1ebc6 tutorial)
Template.map.onCreated(function(){
var self = this
GoogleMaps.ready('map', function(map) {
self.autorun(function(){
self.map = map
plotAllUsers.bind(self)()
var user = Meteor.user()
if (user) {
setupReactiveVarsAndGetCoords(user).then(function(coords){
@MaxPleaner
MaxPleaner / reddit_inbox.rb
Last active April 9, 2016 00:34
ruby method to get reddit inbox
comments = RedditKit::Client.new(REDDIT_USERNAME, REDDIT_PASSWORD).messages.results
puts comments.first(5).map(&:attributes).map do |obj|
<<-TXT
#{obj[:link_title]} (#{obj[:subreddit]})
#{obj[:body]} - #{obj[:author]}
http://reddit.com#{obj[:context]}
TXT
end.join("\n\n")
@MaxPleaner
MaxPleaner / polyrhythm.rb
Created March 12, 2016 00:00
simple ruby class to make a polyrhythm
class Rhythm
attr_reader :num_beats
def initialize(num_beats)
@num_beats = num_beats
end
def to_s
"1 " + (num_beats - 1).times.map { "x" }.join(" ")
end
end
@MaxPleaner
MaxPleaner / with_stdin.rb
Last active February 9, 2016 10:29
with_stdin (pipe to gets.chomp)
# credit http://stackoverflow.com/a/16950202/2949493
def with_stdin
stdin = $stdin # remember $stdin
$stdin, write = IO.pipe # create pipe assigning its "read end" to $stdin
yield write # pass pipe's "write end" to block
ensure
write.close # close pipe
$stdin = stdin # restore $stdin
@MaxPleaner
MaxPleaner / gist:9ba2a9fa2b7a77c8d7bc
Last active January 27, 2016 04:52
html / js drum machine
<!doctype html>
<html>
<head>
<script src="https://rawgit.com/jaysalvat/buzz/master/dist/buzz.js"></script>
<script src="https://code.jquery.com/jquery-git2.min.js"></script>
<style>
.playing {
border: 1px solid red;
}
</style>
$ echo -e "function alia { \n echo -e \"\n function \$1 { \n \$2 \n }\" >> ~/.bashrc \n }" >> ~/.bashrc
# restart shell to use
# usage: $ alia "name" "cmd"
# e.g.: $ alia "gac" "git add -A; git commit -m \"\$1\" "
# $ bash
# $ gac "my commit message"
#
# $1 refers to a variable
# note that $ and " characters are escaped in the alias content