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
#Complex yet elegant | |
class Calc | |
{ zero: 0, one: 1, two: 2, three: 3, four: 4, five: 5, six: 6, seven: 7, eight: 8, nine: 9 }.each do |m, n| | |
define_method("#{m}") { @proc ? @proc.call(n) : (@number ||= n ; self ) } | |
end | |
{ plus: :+, minus: :-, times: :*, divided_by: :/ }.each do |m, o| | |
define_method("#{m}") { @proc ||= lambda { |a| @number.send(o, a) }; self } | |
end | |
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
var myApp = angular.module('myApp', ['myAppController']); |
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 Ranking | |
attr_reader :rankings, :current_rank | |
def initialize | |
@rankings = [-8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8] | |
@rank_index = 0 | |
@current_rank = rankings[@rank_index] | |
end | |
def up | |
return "Already at highest rank" if @rank_index == 15 |
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
1 results = [] | |
2 data = File.open("./weather.txt") do |f| | |
3 lines = f.readlines.drop(2) | |
4 lines.delete_at(-1) | |
5 lines.each do |line| | |
6 temp_hash = Hash.new {|h,k| h[k]={}} | |
7 day,max,min = line.split(' ') | |
8 temp_hash[day] = {min:min,max:max} | |
9 results << temp_hash | |
10 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
require "active_record" | |
module Polite | |
BAD_WORDS = ["fuck", "asshole", "motherfucker", "cunt", "cock", "dickhead"] | |
ESCAPED = BAD_WORDS.collect {|word| Regexp.escape(word)} | |
RE = /(#{ESCAPED.join("|")})/i | |
def self.extended(base) | |
base.extend ClassMethods | |
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
<bean id="authenticationManager" class="org.jasig.cas.authentication.PolicyBasedAuthenticationManager"> | |
<constructor-arg> | |
<map> | |
<entry key-ref="proxyAuthenticationHandler" value-ref="proxyPrincipalResolver" /> | |
<entry key-ref="primaryAuthenticationHandler" value-ref="primaryPrincipalResolver" /> | |
<entry key-ref="ldapAuthenticationHandler" value-ref="usernamePasswordCredentialsResolver" /> | |
</map> | |
</constructor-arg> |
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
/* | |
* Selenium WebDriver JavaScript test with Mocha and NodeJS | |
* | |
* Start with: SELENIUM=PATH_TO_SELENIUM_JAR/selenium-server-standalone-2.31.0.jar mocha -t 10000 -R list google-sample.js | |
* | |
* Download selenium-server-standalone-2.31.0.jar from https://selenium.googlecode.com/files/selenium-server-standalone-2.31.0.jar | |
* 'sudo su' and 'npm install -g colors mocha selenium-webdriver' | |
* | |
* http://visionmedia.github.io/mocha/ | |
* https://code.google.com/p/selenium/wiki/WebDriverJs |
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
[ | |
{ | |
"gender": "female", | |
"name": { | |
"title": "miss", | |
"first": "mary", | |
"last": "jones" | |
}, | |
"email": "mary.jones56@example.com", | |
"username": "crazypeacock512" |
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
{ | |
"type":"concept", | |
"@id":"http://link.aps.org/cs/concepts/dadb5d96-fc29-4c93-8428-3335c7ad1b2a", | |
"id":"dadb5d96-fc29-4c93-8428-3335c7ad1b2a", | |
"legacy_uri":"http://link.aps.org/cs/concepts/dadb5d96-fc29-4c93-8428-3335c7ad1b2a", | |
"label":"Sound detection", | |
"uri":"http://physh.aps.org/concept/dadb5d96-fc29-4c93-8428-3335c7ad1b2a", | |
"paths":[ | |
[ | |
{ |
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
ids = [%w(d b f a), %w(d c a)] | |
hash = {} | |
a.map do |list| | |
list.each_with_index do |v,idx| | |
h = {} | |
h[idx] = v | |
hash.merge!(h) do |_,left,right| | |
Array(left) + Array(right) | |
end | |
hash |