Skip to content

Instantly share code, notes, and snippets.

View thbar's full-sized avatar

Thibaut Barrère thbar

View GitHub Profile
(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) {
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;
# 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)
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
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.
@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
#
@thbar
thbar / gist:4574991
Created January 19, 2013 20:43 — forked from idan/gist:3135754

Hello there! This is a sample post for gist.io, a super-lightweight writing soapbox for hackers.

Now look up. Further. Above the post title. See that grey text with the gist ID?

Now back to me. That grey text is a link! Open that sucker in a new tab to see the source for this post. Also, I'm on a horse.

This is a major heading

If you peek at it with a web inspector, you'll see that it is a second-level heading. You can use first level headings, but they'll look just like the second level ones, and the gods of the HTML5 outlining algorithm will frown upon you.

#!/usr/bin/env ruby
#
# Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156)
#
# ## Advisory
#
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
#
# ## Caveats
#
@thbar
thbar / redis_on_passenger.rb
Created November 28, 2012 21:04 — forked from krasio/redis_on_passenger.rb
config/initializers/redis_on_passenger.rb
# config/initializers/redis_on_passenger.rb
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
# We're in smart spawning mode.
if forked
# Re-establish redis connection
# disconnect
Resque.redis.client.disconnect
@thbar
thbar / gemfile_changelog.rb
Created November 22, 2012 09:07 — forked from swrobel/gemfile_changelog.rb
Get Changelogs for outdated gems in Gemfile
#!/usr/bin/env ruby
def changelog_for_gem(gem)
changelogs = `bundle exec gem contents #{gem}`.lines.grep(/history|changelog|news/i)
if changelogs.empty?
puts "No changelog found for gem #{gem}"
return nil
end