This file contains hidden or 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
FROM node:latest | |
MAINTAINER Andreas Alin | |
ADD package.json /app/package.json | |
RUN cd /app && npm install | |
RUN npm install node-sass | |
COPY . /app | |
WORKDIR /app |
This file contains hidden or 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
class Progress | |
class DefaultFormatter | |
def progress_format(current, total) | |
format("\e[K\e[G %5.2f%% (%s / %s)", current / total.to_f * 100.0, format_number(current), format_number(total)) | |
end | |
def format_number(number) | |
number.to_s.chars.reverse.each_slice(3).map(&:reverse).reverse.map(&:join).join(" ") | |
end | |
end |
This file contains hidden or 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
var TweeningNumber = React.createClass({ | |
mixins: [tweenState.Mixin], | |
getInitialProps: function() { | |
return { | |
value: 0, | |
duration: 500 | |
}; | |
}, | |
getInitialState: function() { | |
return { value: 0 }; |
This file contains hidden or 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
# Based on https://github.com/Sojo-Studios/catmull-rom/blob/master/test.js | |
# This implementation assumes circular splines. | |
class CatmullRomSplines | |
def initialize(points) | |
@key_points = points | |
end | |
def generate(detail) | |
points = [] |
This file contains hidden or 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
# This takes about 1.6 seconds for 800x600 | |
def short_screenshot!(width, height) | |
pixels = glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE) | |
image = ChunkyPNG::Image.from_rgb_stream(width, height, StringIO.new(pixels)) | |
image.flip_horizontally! | |
image.save('screenshot.png', :fast_rgb) | |
end | |
# This takes about 0.8 seconds for 800x600 | |
def long_screenshot!(width, height) |
This file contains hidden or 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
module I18n | |
# Usage (Haml in examples): | |
# | |
# - t_scope(:"public.sign_up_or_log_in") do |s| | |
# = simple_format(s.t(:text, | |
# sign_up: link_to(s.t(:sign_up), signup_path), | |
# log_in: link_to(s.t(:log_in), login_path))) | |
# | |
# is equivalent to | |
# |
This file contains hidden or 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
class ActiveRecord::SchemaDumper | |
def dump(stream) | |
header(stream) | |
tables(stream) | |
sequences(stream) | |
sequence_defaults(stream) | |
trailer(stream) | |
stream | |
end |
This file contains hidden or 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
# encoding: utf-8 | |
class LocaleDiffer | |
RED = 31 | |
GREEN = 32 | |
def initialize | |
load_locales | |
end |
This file contains hidden or 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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require 'yaml' | |
require 'stringio' | |
class LocaleFormatter | |
ESCAPE_KEYS = %w(true false yes no on off) | |
ESCAPE_VALUE_RE = /[^[:alnum:]_\-\/\.\?]/ | |
MULTILINE_INDENT_LEVEL = 2 |
This file contains hidden or 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
# changed line 19 of rubygems/ext/builder.rb from: | |
mf = File.read('Makefile') | |
# into | |
mf = File.read('Makefile', :encoding => 'iso-8859-15').encode('utf-8') | |
# Problem was that qmake generated a Makefile that included a latin 1 "å" in the date because of swedish locales... |