Skip to content

Instantly share code, notes, and snippets.

Michael Mahemoff mahemoff

Block or report user

Report or block mahemoff

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
mahemoff /
Last active Oct 6, 2019
circleci mysql upgrade
set -x
set -e
export DEBIAN_FRONTEND=noninteractive
sudo apt-get --purge autoremove -y mysql-server-5.6
curl -LO
echo mysql-apt-config mysql-apt-config/select-product select Apply | sudo debconf-set-selections
mahemoff / names.txt
Created Apr 5, 2012
Reserved username list
View names.txt
A meta-compilation of:
(Took out some company-specific terms at the top of the first one (e.g. imulus, stacks), added one term so far - 'edits'.)
NOTE: Does not include profanities. You may or may not want to add a list of those.
(See, but don't try to apply regexp's here because Scunthorpe -
mahemoff / Ansible Disk Check
Last active Sep 6, 2019
Show disk space and warn about disk full in Ansible
View Ansible Disk Check
* Shows a message while asserting like:
ok: [host] => {
"msg": "disk usage 4.2B of total 20.0GB (21.0%) (should be within limit 90.0%)"
* Note this only looks at first mount point on current node
* Fails if disk is near-full
* Last step pushes to a push-based monitoring service, which will alert us if it doesn't get there after some time
* Need to setup a variable `disk_limit`, which is the max acceptable usage ratio, e.g. set it to 0.8 if you want to keep disks within 80% of max size
mahemoff / bench.rb
Last active Sep 6, 2019
in versus include
View bench.rb
#!/usr/bin/env ruby
require 'benchmark'
require 'active_support/all'
puts 'in', Benchmark.measure {}
puts 'include', Benchmark.measure { (1..99000).include? 90000 }
View video-client.html
<!-- This is a Node+WebSocket powered demo to sync videos
across different browsers. This file is the client,
the other one is the Node server. Powered by Node and -->
.inactive { display: none; }
.active { display: block; }
mahemoff / parallel_array.rb
Created Jun 29, 2019
Extending Array with Parallel gem
View parallel_array.rb
class Array
%w(each map each_with_index map_with_index flat_map any? all?).each { |meth|
define_method("#{meth}_in_parallel") { |&block|
Parallel.send(meth, self) { |item| }
mahemoff / async-widget-load.html
Created Feb 16, 2015
async freshdesk widget load (general technique for any lib without explicit async support)
View async-widget-load.html
<script src="
s" async='async'></script>
(function() {
var freshTriesRemaining = 12;
setTimeout(function() {
if (typeof(FreshWidget)!='undefined')
else if (freshTriesRemaining-- > 0)
setTimeout(arguments.callee, 250);
mahemoff / application_controller.rb
Created Apr 9, 2015
Cloudflare country detection (geo-ip) in Ruby/Rails
View application_controller.rb
class ApplicationController < ActionController::Base
def cloudflare_country_code
def eu_request? %w(GB FR DE ..... )
mahemoff / uniq.rb
Created Sep 12, 2014
Ensure Sidekiq jobs are unique (if the queue contains several jobs with same class and args, this will delete all but one of them)
View uniq.rb
def self.uniq! queue_name
seen_already = { |job|
key = { job.klass => job.args } ? job.delete : seen_already << key
You can’t perform that action at this time.