Skip to content

Instantly share code, notes, and snippets.

var Nightmare = require('nightmare');
var exec = require('child_process').exec;
// Receive arguments from the console.
var arguments = process.argv.slice(2);
console.log("Searching: " + arguments);
new Nightmare()
.goto('http://yahoo.com')
.type('input[title="Search"]', arguments)
@botanicus
botanicus / index.html
Created August 3, 2014 08:24
Vibrate Android.
<!DOCTYPE html>
<html>
<head>
<script>
var duration = 1000; // 1 sec.
document.addEventListener('DOMContentLoaded', function (event) {
navigator.vibrate(duration);
});
</script>
</head>
source 'https://rubygems.org'
gem 'ppt', path: '/webs/ppt/gems/ppt'
gem 'pipeline.rb', github: 'botanicus/pipeline.rb', branch: 'master' ###### <= This is supposedly the problem.
group(:development, :test) do
gem 'pry'
end
group(:test) do
launch "iTerm"
tell application "iTerm"
activate
set myterm to (make new terminal)
tell myterm
-- SPLIT the terminal to 4 split windows.
tell application "AppleScript Editor"
go fuck yourself
end tell
@botanicus
botanicus / env-edit.rb
Created June 15, 2014 18:12
Modify /etc/environment with ease! Append, prepend to your PATH, define and undefine variables! Last version is always in /etc/environment.bckp.
#!/opt/rubies/ruby-2.1.2/bin/ruby -i.bckp
# Usage:
# ./env-edit.rb [var] delete [optional file]
# ./env-edit.rb [var] [append|prepend|replace|remove] [value] [optional file]
# ./env-edit.rb PATH append /opt/rubies/rbx-2.2.6/bin/rbx
OPERATIONS = ['add', 'delete', 'append', 'prepend', 'replace', 'remove']
variable, operation = ARGV.shift(2)
@botanicus
botanicus / PPT.applescript
Last active September 2, 2018 15:34
Launch iTerm2 session with 3 split windows and run commands in them.
-- Find more at http://iterm.sourceforge.net/scripting.shtml
launch "iTerm"
tell application "iTerm"
activate
-- ssh in split panes to my varnish stack
set myterm to (make new terminal)
tell myterm
@botanicus
botanicus / config.ru
Created May 27, 2014 12:14
Test how cookies work. This code shows that app.example.com can set a cookie for the whole domain and vice versa. (RFC is either not clear or there are disparities between RFC and implementation in browsers, so I just tested it to be sure.)
#!/usr/bin/env rackup -p 9999
run Proc.new { |env|
value = env['QUERY_STRING'].split('&').last
response = Rack::Response.new(["Demo app"], 200, Hash.new)
if value
puts "~ SET #{value}"
response.set_cookie('session-id', {value: value, domain: '101ideas.cz', path: '/', expires: Time.now+24*60*60})
#!/usr/bin/env ruby
# encoding: utf-8
# Usage:
# nef2jpg.rb DSC_5069.NEF
# nef2jpg.rb DSC_50??.NEF
# nef2jpg.rb .
# settings
PROCESSES = 4
# encoding: utf-8
require "pry"
require "dm-core"
require "dm-migrations"
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, "mysql://localhost/test")
DataMapper::Model.raise_on_save_failure = true