Skip to content

Instantly share code, notes, and snippets.

View thbar's full-sized avatar

Thibaut Barrère thbar

View GitHub Profile
@thbar
thbar / proby
Last active December 18, 2015 01:38 — forked from jwood/proby
#!/bin/bash
#
# This script surrounds the command passed in with start and finish notifications
# to the Proby task monitoring application.
#
# Note thbar: this version is modified to properly handle errors when they happen,
# since the original version always returned a success.
#
# === SETUP
#
namespace :db do
namespace :structure do
# A hack to post-process structure.sql so that it's normalized to a
# canonical format that is unlikely to have spurious diffs.
task :dump do
structure_fname = File.join(Rails.root, "db/structure.sql")
raw_contents = File.read(structure_fname)
# 1. ditch AUTO_INCREMENT= clauses.
raw_contents = raw_contents.
check process sidekiq_01
with pidfile /path/to/app/current/tmp/pids/sidekiq.pid
start program = "/bin/sh -c 'cd /path/to/app/current; PATH=bin:/path/to/rbenv/shims:/path/to/rbenv/bin:$PATH nohup bundle exec sidekiq -e production -i 0 -P tmp/pids/sidekiq.pid >> log/sidekiq.log 2>&1 &'" as uid app_user and gid app_group with timeout 90 seconds
stop program = "/bin/sh -c 'cd /path/to/app/current; PATH=bin:/path/to/rbenv/shims:/path/to/rbenv/bin:$PATH bundle exec sidekiqctl stop tmp/pids/sidekiq.pid'" as uid app_user and gid app_group with timeout 90 seconds
if totalmem is greater than 500 MB for 2 cycles then restart # eating up memory?
group sidekiq
check process sidekiq_02
with pidfile /path/to/app/current/tmp/pids/sidekiq.pid-1
start program = "/bin/sh -c 'cd /path/to/app/current; PATH=bin:/path/to/rbenv/shims:/path/to/rbenv/bin:$PATH nohup bundle exec sidekiq -e production -i 1 -P tmp/pids/sidekiq.pid-1 >> log/sidekiq.log 2>&1 &'" as uid app_user and gid app_group with timeout 90 seconds
# Attempt at porting https://gist.github.com/nelhage/4507129 to ruby 2.0
#
# I just removed all traces of Syck
def self.make_yaml_safe!
if defined?(Psych)
Psych.const_set("UnsafeYAML", Class.new(StandardError))
Psych.module_eval do
def self.load(yaml, *args)
result = parse(yaml, *args)
var inject_binding = function (allBindings, key, value) {
//https://github.com/knockout/knockout/pull/932#issuecomment-26547528
return {
has: function (bindingKey) {
return (bindingKey == key) || allBindings.has(bindingKey);
},
get: function (bindingKey) {
var binding = allBindings.get(bindingKey);
if (bindingKey == key) {
binding = binding ? [].concat(binding, value) : value;
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['knockout','jquery','selectize'], factory);
} else {
var selConstructor = (typeof selectize != "undefined")?selectize:$('<select>').selectize().data('selectize').constructor;
factory(ko,$,selConstructor);
}
})(function (ko,$,selectize) {
@thbar
thbar / docx2pdf
Last active August 29, 2015 14:10 — forked from diogo-almeida/docx2pdf
# Path of LibreOffice installation
cd /Applications/LibreOffice.app/Contents/MacOS
# General command
./soffice --headless --convert-to <extention> <path+file>
# Automatically convert all .odt files to pdf
./soffice --headless --convert-to pdf ~/Downloads/*.odt
# To specify an output folder you can add the --outdir option
# config/environment.rb
require File.expand_path('../application', __FILE__)
require File.expand_path('../rollbar', __FILE__)
begin
Rails.application.initialize!
rescue Exception => e
Rollbar.error(e)
raise
module AlertConfirmer
class << self
def reject_confirm_from &block
handle_js_modal 'confirm', false, &block
end
def accept_confirm_from &block
handle_js_modal 'confirm', true, &block
end
@thbar
thbar / nginx.conf
Last active August 29, 2015 14:17 — forked from plentz/nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048