Skip to content

Instantly share code, notes, and snippets.

Joel Low lowjoel

Block or report user

Report or block lowjoel

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
lowjoel / with_temporary_table.rb
Last active Aug 29, 2015
RSpec test group helpers for creating tables.
View with_temporary_table.rb
# Test group helpers for creating tables.
# The latest version can be gound at
module ActiveRecord::TemporaryTable; end
module ActiveRecord::TemporaryTable::TestGroupHelpers
# Defines a temporary table that is instantiated when needed, within a `with_temporary_table`
# block.
# @param [Symbol] table_name The name of the table to define.
# @param [Proc] proc The table definition, same as that of a block given to
# +ActiveRecord::Migration::create_table+
lowjoel / coverage_helper.rb
Last active Jan 30, 2017
Simultaneous Code Coverage Reporting to Coveralls and Code Climate
View coverage_helper.rb
# frozen_string_literal: true
# Simultaneous code coverage reporting to Coveralls and Code Climate.
# Latest version can be found at
require 'simplecov'
module CoverageHelper
class << self
# Helper to include Coveralls/Code Climate coverage, but not require developers to install the
# gem.
View bundle_gem_libs.rb
# This script is to work round the problem of broken RubyMine dependencies for bundle files.
# It uses an undocumented feature for RubyMine (but available in Intellij Idea) to create a
# gems library xml file and update the iml file.
# See Rubymine issues:
# Usage:
lowjoel / MatrixMultiply.x10
Created Mar 25, 2015
Matrix Multiplication in x10
View MatrixMultiply.x10
public class MatrixMultiply {
private interface Matrix[T] {
public def initial(): T;
public def width(): Long;
public def widthRange(): LongRange;
public def height(): Long;
public def heightRange(): LongRange;
lowjoel / elliptic_curve.rb
Last active Aug 29, 2015
View elliptic_curve.rb
class Point
def initialize(x, y)
@x = x
@y = y
def to_s
"(#{@x}, #{@y})"
lowjoel /
Last active Aug 29, 2015, fixed for Windows
# Copyright (c) 2009 Google Inc. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
lowjoel / sleepbot-migrate-to-sleep_as_android.rb
Last active Jul 13, 2019
Migrates SleepBot data to Sleep as Android's format
View sleepbot-migrate-to-sleep_as_android.rb
require 'csv'
# Parses CSV-exported data from SleepBot
def parse_export(row)
# Parse the wake up date
date_to = row[0].split('/')
date_to = + date_to[2].to_i, date_to[1], date_to[0])
# Parse the wake up/sleep times
time_from = row[1].split(':')
lowjoel /
Last active Aug 29, 2015
Running Rubocop from the Command Line, generating a JUnit report
#!/usr/bin/env ruby2.1
# Modified from
require 'fileutils'
# This first part runs Rubocop proper
puts "Executing within: #{Dir.pwd}"
RUBOCOP = 'rubocop -R'
lowjoel /
Last active Aug 29, 2015
Running JSHint from the command line without rake
#!/usr/bin/env ruby
# encoding: utf-8
require 'jshint'
require 'jshint/reporters'
reporter_name = ARGV[0] || :Default
file = ARGV[1]
linter =
lowjoel / gist:b0a2eb7bab69210580d0
Created Jul 25, 2014
mysql2 compile warnings on VC++
View gist:b0a2eb7bab69210580d0
have_header: checking for ruby/thread.h... -------------------- yes
"cl -nologo -Feconftest -IC:/Ruby210/include/ruby-2.1.0/x64-mswin64_120 -IC:/Ruby210/include/ruby-2.1.0/ruby/backward -IC:/Ruby210/include/ruby-2.1.0 -I. -IC:/Ruby210/include/ruby-2.1.0 -MD -Zi -W2 -wd4996 -we4028 -we4142 /O2 /GL -Zm600 conftest.c x64-msvcr120-ruby210.lib oldnames.lib user32.lib advapi32.lib shell32.lib ws2_32.lib iphlpapi.lib imagehlp.lib shlwapi.lib -link -incremental:no -debug -opt:ref -opt:icf -libpath:. -libpath:C:/Ruby210/lib "
Generating code
Finished generating code
checked program was:
/* begin */
1: #include "ruby.h"
You can’t perform that action at this time.