-
Java uses static, declared typing:
String hello = "Hello, World!"; List<String> phrases = new ArrayList<String>; phrases.add(hello); phrases.add(null); phrases.add(123); // Compile error! Not a string.
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
# Not Great PNG class. This is a very simple example of writing a PNG. It | |
# only supports colors from the color palette stored in `@palette`. This is | |
# meant to be example code, but I am using it in a program for visualizing | |
# heap dumps from Ruby. | |
# | |
# This is free and unencumbered software released into the public domain. | |
# | |
# Anyone is free to copy, modify, publish, use, compile, sell, or | |
# distribute this software, either in source code form or as a compiled | |
# binary, for any purpose, commercial or non-commercial, and by any |
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
addmedia | |
addphoto | |
addvideo | |
appinfo | |
boot | |
bootstatus | |
clone | |
create | |
darwinup | |
delete |
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
sudo apt-get update | |
sudo apt-get install libjemalloc-dev | |
RUBY_CONFIGURE_OPTS='--with-jemalloc' rbenv install 2.6.3 | |
# test (look for jemalloc warnings) | |
MALLOC_CONF=invalid_flag:foo ruby -v |
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
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" |
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
# speed up pluck | |
class ActiveRecord::Relation | |
class RailsDateTimeDecoder < PG::SimpleDecoder | |
def decode(string, tuple=nil, field=nil) | |
if Rails.version >= "4.2.0" | |
@caster ||= ActiveRecord::Type::DateTime.new | |
@caster.type_cast_from_database(string) | |
else |
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
class API::V1::BaseController < ApplicationController | |
skip_before_filter :verify_authenticity_token | |
before_filter :cors_preflight_check | |
after_filter :cors_set_access_control_headers | |
def cors_set_access_control_headers | |
headers['Access-Control-Allow-Origin'] = '*' | |
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS' |
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
import Foundation | |
/// An abstract class that makes building simple asynchronous operations easy. | |
/// Subclasses must implement `execute()` to perform any work and call | |
/// `finish()` when they are done. All `NSOperation` work will be handled | |
/// automatically. | |
open class AsynchronousOperation: Operation { | |
// MARK: - Properties |
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 'yaml' | |
require 'erb' | |
require 'ostruct' | |
class Settings < OpenStruct | |
# Settings.new(:google_analytics) | |
def initialize(config_file_base_name) | |
super(YAML.load(ERB.new(File.read(Rails.root.join("config", "#{config_file_base_name}.yml"))).result)[Rails.env]) | |
end |
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
On the shared machine: | |
Download http://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.33.0.jar&can=2&q= | |
$ brew install chromedriver | |
$ java -jar selenium-server-standalone-2.33.0.jar | |
On the local machine: | |
Set `CHROME_HOSTNAME` in your `.env`, `.rbenv_vars`, or per run. |
NewerOlder