It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.
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
name: CI | |
on: [push] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
container: | |
image: ruby:2.6.5 |
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
require "net/http" | |
def start_server | |
# Remove the X to enable the parameters for tuning. | |
# These are the default values as of Ruby 2.2.0. | |
@child = spawn(<<-EOC.split.join(" ")) | |
XRUBY_GC_HEAP_FREE_SLOTS=4096 | |
XRUBY_GC_HEAP_INIT_SLOTS=10000 | |
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8 | |
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0 |
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
public class Perlin { | |
public int repeat; | |
public Perlin(int repeat = -1) { | |
this.repeat = repeat; | |
} | |
public double OctavePerlin(double x, double y, double z, int octaves, double persistence) { | |
double total = 0; |
CoffeeScript 1.7 is shaping up to be a pretty kick-ass release with significant improvements. Here are the ones I'm most excited about, in order of my own excitement.
Years of being wished for, finally granted!
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
require 'stringio' | |
require 'timeout' | |
class Object | |
def methods_returning(expected, *args, &blk) | |
old_stdout = $> | |
$> = StringIO.new | |
methods.select do |meth| | |
Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false |
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 2.1.0 in Production: known bugs and patches | |
Last week, we upgraded the github.com rails app to ruby 2.1.0 in production. | |
While testing the new build for rollout, we ran into a number of bugs. Most of | |
these have been fixed on trunk already, but I've documented them below to help | |
anyone else who might be testing ruby 2.1 in production. | |
@naruse I think we should backport these patches to the ruby_2_1 branch and | |
release 2.1.1 sooner rather than later, as some of the bugs are quite critical. | |
I'm happy to offer any assistance I can to expedite this process. |
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
# Given an array of arrays s = [ [1,2,3], [4,5,6], ... ] | |
# compute the Cartesian product among the elements of s. | |
require 'pp' | |
s = [[1, 2], [3, 4, 5], [6, 7, 8, 9]] | |
pp s[1..-1].inject(s[0]){ |m,v| m = m.product(v).map(&:flatten) } | |
[[1, 3, 6], | |
[1, 3, 7], | |
[1, 3, 8], |
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
$ = jQuery | |
$.fn.lineHeight or= -> | |
if height = @data('lineHeight') | |
return height | |
# Create a hidden div with the same font | |
# properties, then measure its height | |
$shadow = $('<span />') | |
$shadow.css({ |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
NewerOlder