View Dockerfile
# How to Use
# open -a XQuartz
# socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
# docker build . -t ds-xclock
# docker run -e DISPLAY=YOUR_LOCAL_IP_HERE:0 -it ds-xclock
#
# Useful Links:
# https://github.com/moby/moby/issues/8710
# http://kartoza.com/en/blog/how-to-run-a-linux-gui-application-on-osx-using-docker/
View class_definition_in_specs.rb
require 'spec_helper'
describe "Wow Coins" do
let(:klasz_class) do
Class.new do
attr_reader :title
def initialize(properties)
@title = properties[:title]
end
View ssh_config
Host *.staging.something.com
User someuser
ForwardAgent yes
LocalForward localhost:43306 localhost:3306
LocalForward localhost:49200 localhost:9200
LocalForward localhost:49001 localhost:9001
View lambda_calculus.rb
# Rules: A lamda always has 1 parameter, nothing more, nothing less
# Useful Content: https://en.wikipedia.org/wiki/Church_encoding
# Identity lambda
IDENTITY = ->x { x }
# True, returns the first argument
TT = ->x { ->y { x } }
# False, returns the last argument
View class_variable_example.rb
# Ruby Class Variable Examples without @@
# http://www.sitepoint.com/class-variables-a-ruby-gotcha/
class Foo
def self.talk
puts 'Hey! I\'m talking'
end
end
class Bar
View count_words_loop.clj
(defn split-words
[phrase]
(clojure.string/split phrase #"\s"))
(defn count-words
[phrase word]
(let [words (split-words (clojure.string/lower-case phrase))
lower-case-word (clojure.string/lower-case word)]
(loop [head (first words)
tail (rest words)
View vowels_count.clj
(def vowels [\a \e \i \o \u])
(defn convert-to-num [letter]
(if (= (some #{letter} vowels) letter)
1
0)))
(defn count-vowels [phrase]
(reduce + (map convert-to-num (clojure.string/lower-case phrase))))
View composite_pattern.js
// How To Use
// var categories = CategoryModule.Category.all();
// var categoryComposite = new CategoryModule.CategoryComposite('CategoryComposite', categories.categorias, null);
//
// var categoryComposities = categoryComposite.findByName('Bar');
//
// var originalCategories = categoryComposities.map(function(item) {
// return item.original;
// });
View ruby_method_visibility.rb
class Sample
attr_accessor :protected_attribute, :private_attribute
protected :protected_attribute=
private :private_attribute=
def initialize
self.protected_attribute = 'some protected value'
self.private_attribute = 'some private value'
end
end
View browser_speech.js
// Initialize the speech object
var speech = new webkitSpeechRecognition;
speech.continuous = true;
speech.interimResults = true;
speech.lang = 'pt-BR';
// Log the message
speech.onresult = function(e){
console.log(e.results[e.results.length-1][0].transcript);
}