Skip to content

Instantly share code, notes, and snippets.

require 'fileutils'
Dir['test/**.jpg'].each do |f|
dirname = File.dirname(f)
filename = File.basename(f)
new_filename = filename.gsub(/IMG_([0-9]+)/, "reU-")
puts "#{dirname}/#{filename} => #{dirname}/#{new_filename}"
FileUtils.mv "#{dirname}/#{filename}", "#{dirname}/#{new_filename}"
end
@ianneub
ianneub / example.rb
Created December 9, 2012 02:56
Shopify API tweak to easily paginate API calls
ShopifyAPI::Customer.find_all do |customer|
# do something with the customer
end
ShopifyAPI::Order.find_all(:status => :any) do |order|
# do something with the order
end
ShopifyAPI::Product.find_all(:limit => 250) do |order|
# do something with the product
### Keybase proof
I hereby claim:
* I am ianneub on github.
* I am ianneub (https://keybase.io/ianneub) on keybase.
* I have a public key ASBfrquH1MPI5aGa9lKPxv9opwiggox8AeQHrGMUiNy2mQo
To claim this, I am signing this object:
@ianneub
ianneub / crate.yml
Created April 30, 2015 19:30
Tutum.co stack yaml to create a crate.io cluster
proxy:
image: tutum/haproxy
environment:
- BACKEND_PORT=4200
ports:
- "4200:80"
links:
- crate
roles:
- global
@ianneub
ianneub / dbclock.rb
Last active December 24, 2015 16:08
First attempt at a database backed clockwork scheduler. This was made against Rails 4 with a Job model that can be created like so: rails g model Job period:string name:string code:text See: https://github.com/tomykaira/clockwork/issues/25
# version 1
require 'clockwork'
require './config/boot'
require './config/environment'
module DBBackedClockwork
extend Clockwork
# add a periodic job to update @@events
@ianneub
ianneub / ec2.log
Created June 26, 2013 15:51
Comparing DNS checks when running `hostname -r` in both VPC and non-VPC EC2 instances.
Non - VPC
sudo tcpdump -nieth0 -s0 port 53
hostname -f
15:47:51.310998 IP 10.117.95.179.44198 > 172.16.0.23.53: 44142+ AAAA? ip-10-117-95-179.ec2.internal. (47)
15:47:51.311358 IP 172.16.0.23.53 > 10.117.95.179.44198: 44142 0/1/0 (108)
15:47:51.311785 IP 10.117.95.179.37773 > 172.16.0.23.53: 50187+ AAAA? ip-10-117-95-179. (34)
15:47:51.312091 IP 172.16.0.23.53 > 10.117.95.179.37773: 50187 NXDomain 0/1/0 (109)
15:47:51.312303 IP 10.117.95.179.57413 > 172.16.0.23.53: 3240+ A? ip-10-117-95-179.ec2.internal. (47)
15:47:51.312517 IP 172.16.0.23.53 > 10.117.95.179.57413: 3240 1/0/0 A 10.117.95.179 (63)
@ianneub
ianneub / console.log
Last active December 18, 2015 10:29
Error when installing vagrant-berkshelf on Windows XP SP3.
C:\Documents and Settings\Ian>vagrant plugin install vagrant-berkshelf
Installing the 'vagrant-berkshelf' plugin. This can take a few minutes...
C:/HashiCorp/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:556:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
C:/HashiCorp/Vagrant/embedded/bin/ruby.exe extconf.rb
creating Makefile
make
generating generator-i386-mingw32.def
compiling generator.c
{
"error": {
"context": null,
"message": "The Response content must be a string or object implementing __toString(), "boolean" given.",
"code": 500,
"trace": [
"0 /opt/dreamfactory/bootstrap/cache/compiled.php(15601): Symfony\\Component\\HttpFoundation\\Response->setContent(false)",
"1 /opt/dreamfactory/bootstrap/cache/compiled.php(15114): Illuminate\\Http\\Response->setContent(Array)",
"2 /opt/dreamfactory/bootstrap/cache/compiled.php(15123): Symfony\\Component\\HttpFoundation\\Response->__construct(Array, 200, Array)",
"3 /opt/dreamfactory/vendor/dreamfactory/df-core/src/Utility/ResponseFactory.php(155): Symfony\\Component\\HttpFoundation\\Response::create(Array, 200, Array)",
@ianneub
ianneub / tutum.yml
Created May 29, 2015 22:47
Cleaned up YAML from the blog post: Log Searching and Analysis with Tutum and an ELK - http://blog.tutum.co/2015/05/26/log-searching-and-analysis-with-tutum-and-an-elk-2/
elasticsearch-data:
image: 'alpine'
command: '/bin/true'
volumes:
- '/data/elasticsearch:/usr/share/elasticsearch/data'
elasticsearch:
image: 'elasticsearch:1.5'
ports:
- '9200:9200'
auth:
image: 'ianneub/google-auth-proxy:latest'
command: '-upstream="http://kibana:5601/" -cookie-secret="asdfasdf" -http-address=0.0.0.0:80 -cookie-expire=8h0m0s'
environment:
- EMAIL_LIST=jdoe@domain.com\nasdf@domain.com
- OAUTH2_PROXY_CLIENT_ID=asdf-asdf.apps.googleusercontent.com
- OAUTH2_PROXY_CLIENT_SECRET=asdfasdf
- 'VIRTUAL_HOST=https://kibana.domain.com'
expose:
- '80'