Skip to content

Instantly share code, notes, and snippets.

Andrew Kane ankane

Block or report user

Report or block ankane

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View devise_notifications.md

Devise email change notifications with encrypted attributes in Rails 5.2

Add to the Devise initializer:

config.send_email_changed_notification = true

Use this PR for attr_encrypted

View pickparams.c
#include <stdio.h>
#include <inttypes.h>
#include <math.h>
// Function, which calculates N, p and r from opslimit and memslimit copied from
// libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c
int pickparams(unsigned long long opslimit, const size_t memlimit,
uint32_t *const N_log2, uint32_t *const p, uint32_t *const r) {
unsigned long long maxN;
unsigned long long maxrp;
View searchkick_repro.rb
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "activerecord", require: "active_record"
gem "activejob", require: "active_job"
gem "sqlite3"
gem "searchkick", git: "https://github.com/ankane/searchkick.git"
end
View Effective_Engineer.md

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

View rails-with-bower.md
@ankane
ankane / time_zone_support.sql
Last active Feb 22, 2018
Time zone support for MySQL
View time_zone_support.sql
This file has been truncated, but you can view the full file.
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
START TRANSACTION;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
SET @time_zone_id= LAST_INSERT_ID();
INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('Africa/Abidjan', @time_zone_id);
INSERT INTO time_zone_transition (Time_zone_id, Transition_time, Transition_type_id) VALUES
View median.sql
-- median
-- http://www.postgresonline.com/journal/archives/67-Build-Median-Aggregate-Function-in-SQL.html
CREATE OR REPLACE FUNCTION array_median(numeric[])
RETURNS numeric AS
$$
SELECT CASE
WHEN array_upper($1,1) = 0 THEN null
WHEN mod(array_upper($1,1),2) = 1 THEN asorted[ceiling(array_upper(asorted,1)/2.0)]
ELSE ((asorted[ceiling(array_upper(asorted,1)/2.0)] + asorted[ceiling(array_upper(asorted,1)/2.0)+1])/2.0) END
@ankane
ankane / map.html.slim
Created Mar 29, 2013
Super-simple Google Maps
View map.html.slim
= javascript_include_tag "http://maps.googleapis.com/maps/api/js?sensor=false"
#map style="height: 500px;"
javascript:
var pings = #{@pings.to_json(root: false).html_safe};
$(document).ready( function() {
var mapOptions = {
zoom: 13,
View README.md

Benchmark Bundler

Because loading gems can take longer than you think

Now available as a gem - get it here

View heroku_pg_push.sh
#!/bin/bash
# From http://chrismccord.com/blog/2013/01/09/better-heroku-db-push-and-db-pull/
#
# Postgres equivalent to heroku db:push.
# Pushes local database up to heroku application database.
#
# Requirements: psql --version >= 9.2.2
#
# Usage:
You can’t perform that action at this time.