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
def score(dice) | |
return 0 if dice.empty? | |
counts = Hash.new(0) | |
dice.each do |die| | |
counts[die] += 1 | |
end | |
a_set = (counts.select {|k, v| v > 2}) | |
set = a_set[0][0] if a_set.empty? == false | |
counts[set] -= 3 if set != nil |
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
def is_anagram?(words) | |
one, two = words.split ", " | |
two_arr = two.split "" | |
one.chars do |o| | |
two_arr.delete(o) { return false } | |
end | |
true | |
end | |
puts is_anagram? "word, wrod" # => True |
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
#!/bin/bash | |
function append_filename { | |
echo -en >> $TOCFILE "TRACK AUDIO\nFILE \"$WAV\" 0\n" | |
} | |
MP3DIR=$1 | |
TOCFILE="cd_$$.toc" | |
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") |
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/ftp' | |
require 'time' | |
metar_uri = 'tgftp.nws.noaa.gov' | |
metar_base = '/data/observations/metar/stations/' | |
metar_station = ARGV[0] | |
metar_file = metar_station + '.TXT' | |
metar_data = Array.new |
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
protected String getUserIdFromPrincipal( Principal prin ) { | |
try { | |
if ( prin == null ) { | |
return ""; | |
} | |
String decodedPrin = URLDecoder.decode( prin.toString(), "UTF-8" ); | |
// Not in CN=xyz format? Then just return full name up to first space, if 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
protected String getUserIdFromPrincipal(Principal prin) { | |
if (prin == null) { | |
throw new IllegalArgumentException( | |
"User principal must not be null."); | |
} | |
logger.debug("URL encoded principal: " + prin); | |
String strPrincipal = null; | |
try { | |
strPrincipal = URLDecoder.decode(prin.getName(), UTF_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
package com.cinfin.sharedsvcs.ems.payload; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
import java.util.zip.*; | |
/** | |
* Singleton class for performing compression/decompression operations on | |
* payload byte arrays. | |
* |
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
for (Iterator<String> iterator = o.iterator(); iterator.hasNext();) { | |
iterator.next(); | |
iterator.remove() | |
} |
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
FactoryGirl.define do | |
factory :user do | |
name "#{Faker::Name.first_name} #{Faker::Name.last_name}" | |
email Faker::Internet.email | |
username Faker::Internet.user_name | |
password 'password' | |
stripe_customer_id 'cus_1' | |
factory :deactivated_user do | |
deactivated true |
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
FactoryGirl.define do | |
factory :user do | |
name 'Test User' | |
email '[email protected]' | |
trait :admin do | |
# Setting name here isn't required. Given to show override. | |
name 'Test Admin' | |
admin true | |
end |
OlderNewer