This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Google Translate automatic for the people ! | |
* | |
* - visit http://translate.google.com make sure instant translation is on | |
* - set source and target languages and open firebug | |
* - copy your JSON translation object in (string key/value pairs) : | |
* var input = { "hello.world": "Hello World !", ... }; | |
* - make sure non of your values to be translated end with '...' ! | |
* - declare and output object where translations will be stored : | |
* var output = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* $.parseParams - parse query string paramaters into an object. | |
*/ | |
(function($) { | |
var re = /([^&=]+)=?([^&]*)/g; | |
var decodeRE = /\+/g; // Regex for replacing addition symbol with a space | |
var decode = function (str) {return decodeURIComponent( str.replace(decodeRE, " ") );}; | |
$.parseParams = function(query) { | |
var params = {}, e; | |
while ( e = re.exec(query) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Allows for an #override annotation for your methods. | |
# Thus might help you during refactoring (method renaming) to assure methods | |
# expected to call a super will fail early during loading instead of runtime. | |
# | |
# Sample : | |
# | |
# class Message | |
# extend Override | |
# | |
# def do_send; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record/log_subscriber' | |
class SlowQueryLog < ActiveSupport::LogSubscriber | |
if Rails.configuration.respond_to?(:slow_query_log_threshold_in_ms) | |
if @@threshold = Rails.configuration.slow_query_log_threshold_in_ms | |
@@threshold = @@threshold.to_i == 0 ? nil : @@threshold.to_i | |
end | |
else | |
@@threshold = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* jsUnity Universal JavaScript Testing Framework v0.6 | |
* http://jsunity.com/ | |
* | |
* Copyright (c) 2009 Ates Goral | |
* Licensed under the MIT license. | |
* http://www.opensource.org/licenses/mit-license.php | |
* | |
* Copyright (c) 2010 Karol Bucek - FBJS compatible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# reproducer for https://github.com/jruby/jruby-openssl/issues/236 | |
# If a certificate has two trust paths, jruby doesn't prioritize using non expired certificates, while CRuby (openssl 1.1.1+) does | |
# In this reproducer we have a leaf certificate with two possible chains: | |
# a) leaf -> intermediate cert A -> ISRG Root X1 cross-signed by (expired) DST ROOT CA X3 -> (expired) DST ROOT CA X3 | |
# b) leaf -> intermediate cert B -> ISRG Root X1 | |
# JRuby will produce chain a) causing an error, while CRuby produces a valid chain b) | |
require 'openssl' | |
require 'net/http' | |
def cert_from_url(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Recurring Job using Delayed::Job | |
# | |
# Setup Your job the "plain-old" DJ (perform) way, include this module | |
# and Your handler will re-schedule itself every time it succeeds. | |
# | |
# Sample : | |
# | |
# class MyJob | |
# include Delayed::ScheduledJob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
rabbitmq { | |
codec => plain | |
host => "localhost" | |
key => "#" | |
exchange => "sysmsg" # string (optional) | |
queue => 'dur-no-policy-4' | |
durable => true | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/evn ruby | |
# (Not just) Nokia 2 Android SMS converter script. | |
# | |
# This tool assumes you've backed up your SMS messages from your device using | |
# Gammu (Wammu) http://wammu.eu/wammu/ in XML format e.g. | |
# | |
# * open Wammu and connect your phone: Phone -> Connect | |
# * retrieve messages (or all) using: Retrieve -> Messages | |
# * backup as XML using: Backups -> Export messages to XML |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# force -Xjit.max setting on JRuby <= 9.2.8 | |
# | |
# forcing is not perfect - | |
# counter for existing methods will still keep incrementing but compilation is expected to halt | |
# | |
# @note -Xjit.max has no effect on JRuby 9K - its only enforced since 9.2.9 | |
# | |
(Class.new do |
NewerOlder