Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lowjoel
lowjoel / gist:b0a2eb7bab69210580d0
Created July 25, 2014 00:39
mysql2 compile warnings on VC++
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 "
conftest.c
Generating code
Finished generating code
checked program was:
/* begin */
1: #include "ruby.h"
2:
@lowjoel
lowjoel / jshint.sh
Last active August 29, 2015 14:04
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 = Jshint::Lint.new
@lowjoel
lowjoel / rubocop.sh
Last active August 29, 2015 14:04
Running Rubocop from the Command Line, generating a JUnit report
#!/usr/bin/env ruby2.1
# Modified from
# https://github.com/clintoncwolfe/chef-ci-tools/blob/master/bin/rubocop-junit-tee.rb
require 'fileutils'
# This first part runs Rubocop proper
puts "Executing within: #{Dir.pwd}"
RUBOCOP_XML = ARGV.shift
RUBOCOP_JSON = "#{RUBOCOP_XML}.json"
RUBOCOP = 'rubocop -R'
@lowjoel
lowjoel / cpplint.py
Last active August 29, 2015 14:06
cpplint.py, fixed for Windows
#!/usr/bin/python
#
# 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
lowjoel / elliptic_curve.rb
Last active August 29, 2015 14:08
elliptic_curve.rb
class Point
def initialize(x, y)
@x = x
@y = y
end
def to_s
"(#{@x}, #{@y})"
end
@lowjoel
lowjoel / MatrixMultiply.x10
Created March 25, 2015 04:02
Matrix Multiplication in x10
import x10.io.Console;
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;
# 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:
# https://youtrack.jetbrains.com/issue/RUBY-16428
# https://youtrack.jetbrains.com/issue/RUBY-15026
# https://youtrack.jetbrains.com/issue/RUBY-14542
#
# Usage:
@lowjoel
lowjoel / Matric.js
Created August 24, 2013 13:59
NUS Matriculation Number Checksum
function matric(noLetter) {
var type = noLetter.charAt(0);
if (type === 'U') {
type = 1;
var weights = [6, 11, 12, 10, 12, 0];
} else if (type === 'A') {
type = 2;
var weights = [-1, -1, -1, -1, -1, -1];
} else {
return undefined;
@lowjoel
lowjoel / coverage_helper.rb
Last active January 30, 2017 06:27
Simultaneous Code Coverage Reporting to Coveralls and Code Climate
# frozen_string_literal: true
# Simultaneous code coverage reporting to Coveralls and Code Climate.
# Latest version can be found at https://gist.github.com/lowjoel/6c2f2d3a08bb3786994f
require 'simplecov'
module CoverageHelper
class << self
# Helper to include Coveralls/Code Climate coverage, but not require developers to install the
# gem.
#
@lowjoel
lowjoel / sleepbot-migrate-to-sleep_as_android.rb
Last active July 13, 2019 10:57
Migrates SleepBot data to Sleep as Android's format
require 'csv'
# Parses CSV-exported data from SleepBot
def parse_export(row)
# Parse the wake up date
date_to = row[0].split('/')
date_to = Time.new(2000 + date_to[2].to_i, date_to[1], date_to[0])
# Parse the wake up/sleep times
time_from = row[1].split(':')