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
# frozen_string_literal: true | |
class ApplicationRecord < ActiveRecord::Base | |
self.abstract_class = true | |
class << self | |
def approximate_row_count(table_name = arel_table.name) | |
results = ActiveRecord::Base.connection_pool.with_connection { |c| | |
c.execute("SELECT reltuples::BIGINT AS approximate_row_count FROM pg_class WHERE relname = '#{table_name}'") | |
} | |
results.present? ? results.first['approximate_row_count'].to_i : nil | |
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
ruby -r webrick/httpproxy -e 's = WEBrick::HTTPProxyServer.new(:Port => 9999, :RequestCallback => Proc.new{|req,res| puts req.request_line, req.raw_header}); trap("INT"){s.shutdown}; s.start' |
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
class LogentriesAlertsController < ApplicationController | |
skip_before_action :verify_authenticity_token | |
def create | |
return head(:unprocessable_entity) unless | |
LogentriesAuth.new(request).authorized? | |
if what =~ /R1[45]/ && | |
who =~ /web\.\d+/ | |
Redis.current.set( |
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
# Check authenticity of a logentries.com webhook | |
# cf: https://logentries.com/doc/webhookalert/ | |
# cf: https://blog.logentries.com/2013/02/webhooks-are-hmac-authenticated/ | |
require 'openssl' | |
require 'base64' | |
require 'digest/md5' | |
class LogentriesAuth | |
attr_reader :request |
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 _css = require("./sticky_heading_list.scss"); | |
// import from https://github.com/polarblau/stickySectionHeaders | |
// requires jQuery as a global | |
(function($){ | |
/* A little helper to calculate the sum of different | |
* CSS properties | |
* | |
* EXAMPLE: | |
* $('#my-div').cssSum('paddingLeft', 'paddingRight'); |
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
# === Plugins === | |
require './lib/puma/plugin/redis_stop_puma' | |
plugin 'redis_stop_puma' |
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
source 'https://rubygems.org' | |
gem 'octopress', '~> 3.0' | |
# gem 'drjekyll' | |
gem 'html2markdown' | |
group :jekyll_plugins do | |
gem 'octopress-codefence' | |
gem 'octopress-debugger' |
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
class BankAccount < ActiveRecord::Base | |
# :identifier is a column in "bank_accounts" | |
delegate :name, to: :balanced_api | |
private | |
def balanced_api | |
@balanced_api ||= begin | |
Balanced::BankAccount.fetch(identifier) |
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
{ | |
"status": 201, | |
"data": { | |
"bank_name": "SAN MATEO CREDIT UNION", | |
"_type": "bank_account", | |
"_uris": { | |
"debits_uri": { | |
"_type": "page", | |
"key": "debits" | |
}, |
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
# http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/ | |
execute "mistrust ctime" do | |
command "git config --global core.trustctime #{node['git']['trustctime'].to_s }" | |
user node['current_user'] | |
end |
NewerOlder