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 'uri' | |
# There's a bug in jboss or torquebox where encoded backslashes in URLs are incorrectly converted into forward slashes. | |
# This is rack middleware that detects when the original request included a backslash and will correct the env variable | |
# before forwarding it to the other middleware | |
# See https://issues.jboss.org/browse/TORQUE-955 | |
class TorqueboxBackslashFixMiddleware | |
ENCODED_BACKSLASH = "%5C" |
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
// MySQL to Google Spreadsheet By Pradeep Bheron | |
// Support and contact at pradeepbheron.com | |
function myMySQLFetchData() { | |
var conn = Jdbc.getConnection('jdbc:mysql://127.0.0.1:3306/employee_db', 'username', 'pass'); // Change it as per your database credentials | |
var stmt = conn.createStatement(); | |
var start = new Date(); // Get script starting time | |
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
def move_rows(from_batch_id, to_batch_id = 3539, errors_batch_id: 3558, execute: false, move_rows: :affected) | |
swap_ids_query = <<SWAP_IDS_QUERY | |
SELECT | |
to_br.internal_id, | |
to_br.service_type, | |
count(DISTINCT to_br.eligible_batch_id) to_batches_count, | |
count(DISTINCT from_br.eligible_batch_id) from_batches_count, | |
GROUP_CONCAT(DISTINCT to_br.id) to_br_ids, | |
GROUP_CONCAT(DISTINCT from_br.id) from_br_ids, | |
count(DISTINCT to_br.id) to_br_id_count, |
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
module ActiveRecord | |
module ScopedBatches | |
def scoped_find_each(options = {}) | |
scoped_find_in_batches(options) do |records| | |
records.each { |record| yield record } | |
end | |
end | |
def scoped_find_in_batches(options = {}) |
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
// without callback | |
Array.prototype.eachSlice = function (size){ | |
this.arr = [] | |
for (var i = 0, l = this.length; i < l; i += size){ | |
this.arr.push(this.slice(i, i + size)) | |
} | |
return this.arr | |
}; | |
[1, 2, 3, 4, 5, 6].eachSlice(2) |
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/env ruby | |
# Put this file in the root of your Rails project, | |
# then run it to output the SQL needed to change all | |
# your tables and columns to the same character set | |
# and collation. | |
# | |
# > ruby character_set_and_collation.rb | |
DATABASE = '' |
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
function computeHttpSignature(config, headerHash) { | |
var template = 'keyId="${keyId}",algorithm="${algorithm}",headers="${headers}",signature="${signature}"', | |
sig = template; | |
// compute sig here | |
var signingBase = ''; | |
config.headers.forEach(function(h){ | |
if (signingBase !== '') { signingBase += '\n'; } | |
signingBase += h.toLowerCase() + ": " + headerHash[h]; | |
}); |
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
var index = request.url.indexOf('/'); | |
var uri_path = request.url.substring(index); | |
var payload = uri_path + request.data; | |
console.log("Using payload as " + payload) | |
var hash = CryptoJS.HmacSHA256(payload, environment.secret); | |
var hashInBase64 = CryptoJS.enc.Hex.stringify(hash); | |
postman.setGlobalVariable("signature", hashInBase64); | |
// @see http://gauravds.blogspot.com/2016/06/creating-hmac-in-postman-using-cryptojs.html |
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
#!/bin/zsh | |
# Opens a zoom meeting with the name you've given it. | |
# Drop this script in /usr/local/bin/openzoom | |
# Invoke with `openzoom meeting_name` | |
typeset -A meeting | |
# NOTE: set this hashmap with meeting_name and ids of that meeting | |
meeting[meeting_name]=123456789 |
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
Capybara.register_driver :chrome do |app| | |
Capybara::Selenium::Driver.new(app, | |
browser: :chrome, | |
desired_capabilities: { | |
"chromeOptions" => { | |
"args" => %w{ window-size=1024,768 } | |
} | |
} | |
) | |
end |