Skip to content

Instantly share code, notes, and snippets.

# inspired by http://ariejan.net/2010/08/23/resque-how-to-requeue-failed-jobs
# retry all failed Resque jobs except the ones that have already been retried
# This is, for instance, useful if you have already retried some jobs via the web interface.
Resque::Failure.count.times do |i|
Resque::Failure.requeue(i) unless Resque::Failure.all(i, 1)['retried_at'].present?
end
# retry all :)
Resque::Failure.count.times do |i|
require 'benchmark'
def zip_it(array1,array2)
Hash[array1.zip(array2)]
end
def naive(array1,array2)
hash = {}
@maciejkowalski
maciejkowalski / postgres_logs.sh
Last active March 1, 2017 19:48 — forked from pallymore/command.sh
PostgreSQL logging
# MAC OS X
tail -f ~/Library/Application\ Support/Postgres93/var/pg_log/*
# UBUNTU
tail -f /var/lib/postgresql/9.3/main/pg_log/*
@maciejkowalski
maciejkowalski / hstore_extension.db.rake
Created March 21, 2014 13:15
Add PostgreSQL Hstore extension to structure.sql (HACK
namespace :db do
namespace :structure do
task :add_hstore_extension do
puts "HACK! Adding `CREATE EXTENSION hstore SCHEMA hstore;` to structure.sql (see db_strucute_dump.rake)"
structure_dump = Rails.root + "db/structure.sql"
new_structure_dump = Rails.root + "db/new_structure.sql"
new_file = File.open(new_structure_dump, 'w')
existing = File.open(structure_dump)
require 'open-uri'
require 'nokogiri'
require 'benchmark'
url = 'http://stackoverflow.com/questions/8214299/xpath-or-css-parsing-faster-for-nokogiri-on-html-files'
page = Nokogiri::HTML(open(url))
Benchmark.bmbm do |parser|
parser.report('Xpath') { 1000.times do page.at_xpath('//div[@id="sidebar"]//a[@class="question-hyperlink"]').text end }
@maciejkowalski
maciejkowalski / keras_pydata_warsaw_jan2017.ipynb
Created January 12, 2017 23:42 — forked from stared/keras_pydata_warsaw_jan2017.ipynb
First steps in deep learning with Keras @ PyData Warsaw Meetup (12 Jan 2017)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maciejkowalski
maciejkowalski / gist:04154e5355fceb418fff361ee62ccffb
Created January 28, 2017 17:55 — forked from johnantoni/gist:07df65898456ace4307d5bb6cbdc7f51
Nginx, PHP-FPM, MySQL and phpMyAdmin on OS X

This is my take on how to get up and running with NGINX, PHP-FPM, MySQL and phpMyAdmin on OSX Yosemite.

This article is adapted from the original by Jonas Friedmann. Who I just discovered is from Würzburg in Germany. A stonesthrow from where I was born ;)

Xcode

Make sure you have the latest version of XCode installed. Available from the Mac App Store.

Install the Xcode Command Line Tools:

xcode-select --install

@maciejkowalski
maciejkowalski / simple_git.md
Created March 10, 2017 20:16 — forked from 17twenty/simple_git.md
A Simple Git branching model

a simple git branching model

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

The gist

@maciejkowalski
maciejkowalski / redshift.conf
Created September 7, 2018 22:58 — forked from bcomnes/redshift.conf
My configuration file for Redshift. Place it in ~/.config/ Drag redshift onto the Startup Applications menu to have it boot on start
; Global settings
[redshift]
temp-day=6500K
temp-night=5000
transition=1
;gamma=0.8:0.7:0.8
gamma=1.000:1.000:1.000
location-provider=geoclue
;location-provider=manual
adjustment-method=vidmode
@maciejkowalski
maciejkowalski / godaddy-ssl-howto
Created January 30, 2019 16:25 — forked from ideaoforder/godaddy-ssl-howto
GoDaddy + Nginx SSL
openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
http://support.godaddy.com/help/article/3601/generating-a-certificate-signing-request-nginx
http://support.godaddy.com/help/article/4976/rekeying-an-ssl-certificate
# Be sure to remember to chain them!
cat gd_bundle-g2-g1.crt >> yourdomain.crt
# Move 'em
sudo mv yourdomain.crt /etc/ssl/certs/yourdomain.crt