Ernesto Tagwerker etagwerker

View process-all-jobs-in-sidekiq-queues.rb
1 2 3 4 5
q = Sidekiq::Queue.new
q.each do |job|
# Is this the best way?
Object.const_get(job.klass).new.perform *job.args
end
View register_first_buy_later.liquid
1 2 3 4 5
{% if current_user.is_customer? %}
permitir comprar
{% else %}
registrate, chabón!
{% endif %}
View changed-attributes-nonsense-backbone-js
1 2 3 4 5 6 7 8 9 10
Order = Backbone.Model.extend({
initialize: function() {
this.bind("change:shipping_method_id", this.persist);
},
 
...
 
// If the Order is valid, it tries to persist it.
persist: function(model, name) {
if (this.vanillaValid("#checkout_form_confirm")) {
View incremental-backups-percona-xtrabackup.sh
1 2 3 4 5 6
STAMP=`date +%Y%m%d%H%M`
echo "Iniciando backup @ $STAMP"
mkdir -p /var/backups/$STAMP
LAST_DIR=`ls /var/backups/inc | sort -n | tail -1`
xtrabackup --use-memory=1G --backup --target-dir=/var/backups/inc/$STAMP --incremental-basedir=/var/backups/inc/$LAST_DIR --user=root --password=<root-password>
echo "Fin backup @ $STAMP"
View csv-to-yaml.rb
1 2 3 4 5 6 7 8 9 10
require 'csv'
require 'yaml'
 
array = []
i = 0
CSV.foreach 'mentions.csv' do |l|
hash = {}
hash['url'] = l[2]
hash['date'] = l[1]
hash["mention_#{i}"] = ''
View csv2json ruby script
1 2 3 4 5 6 7 8 9 10
require 'csv'
require 'json'
 
csv =CSV.parse(File.read('lib/data/GeoPC_Regions_ISO3166_2.csv'),{:col_sep => ";"})
 
JS = []
 
csv.each do |row|
h = {iso: row[0],
country: row[1],
View fucking-enies
1 2 3 4 5 6 7 8 9
bonsai ombu_store$ ping caño.local
PING caño.local (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.054 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.127 ms
^C
--- caño.local ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.054/0.090/0.127/0.037 ms
bonsai ombu_store$ lynx caño.local
View liquid will paginate
1 2 3 4 5 6 7 8 9 10
# Paginate a collection
#
# Usage:
#
# {% paginate contents.projects by 5 %}
# {% for project in paginate.collection %}
# {{ project.name }}
# {% endfor %}
# {% endpaginate %}
#
View ombu-shop-api-variant-update
1 2 3 4 5 6 7 8 9 10
PUT /admin/variants/#{sku}.json
 
# Request
{
"variant": {
"sku": "remera-lacoste-verde",
"count_on_hand": 27
}
}
View gist:2420319
1 2 3 4 5 6
# I'd like an in-memory database to do this
 
ISO4217.create(:code => 'BBD', :num => '052', :separator_digits => '2', :currency => 'Barbados dollar', :locations => ['Barbados'])
 
ISO4217.find(:locations => 'Barbados')
=> #<ISO4217:0x007ff62a989b80 @code="BBD" @currency="Barbados dollar">
Something went wrong with that request. Please try again.