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
# Converts from base 10 to a different base | |
def get_digit(digit) | |
digit.to_i > 9 ? sprintf("%0X",digit.to_i) : digit.to_s | |
end | |
def to_base(input,new_base) | |
raise "Number base should be between 2 and 16!" if ((new_base > 16) || (new_base < 2)) | |
raise "Input number must be an unsigned integer!" if (input < 0) | |
return 0 if input == 0 |
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 'cgi' | |
require 'active_support/all' | |
WHITELIST_CHAR_FRENCH_UTF8 = | |
["\xC3\x80", "\xC3\x84", "\xC3\x88", "\xC3\x89", "\xC3\x8A", "\xC3\x8B", "\xC3\x8E", "\xC3\x8F", "\xC3\x94", "\xC3\x99", "\xC3\x9B", | |
"\xC3\x9C", "\xC3\x87", "\xC3\xA0", "\xC3\xA2", "\xC3\xA4", "\xC3\xA8", "\xC3\xA9", "\xC3\xAA", "\xC3\xAB", "\xC3\xAE", "\xC3\xAF", | |
"\xC3\xB4", "\xC3\xB9", "\xC3\xBB", "\xC3\xBC", "\xC3\xBF", "\xC3\xA7"].join | |
WHITELIST_CHAR_FRENCH_ISO8859_1 = | |
"\300\304\310\311\312\313\316\317\324\331\333\334\307\340\342\344\350\351\352\353\356\357\364\371\373\374\377\347"+ |
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
module Rack::MiniServer | |
def start | |
@server_pid = fork do | |
puts "start forking ..." | |
Rack::Handler::WEBrick.run( | |
Rack::ShowExceptions.new(Rack::Lint.new(self.new)), :Port => 9292) do |server| | |
['INT', 'TERM'].each{ |signal| trap(signal){ puts "shutting down"; server.shutdown} } | |
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
#!/bin/bash | |
# | |
# Run this in the background and keep it running when you log out run it like this: | |
# nohup /tmp/trigger_javadump.sh >/tmp/trigger_javadump.log 2>&1 & | |
# | |
FULLGC_PATTERN='^Application time: 0.0000' | |
VERBOSEGC_PATH='verbosegc.log' | |
while true; do | |
FULLGC_FOUND=$(grep "$FULLGC_PATTERN" "$VERBOSEGC_PATH") |
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
one_million = (1..1e6).to_a | |
one_million_sum = (1.0e6+1)*1.0e6/2 | |
missing = one_million.delete(rand(one_million.size)) | |
one_million_minus_missing_sum = one_million.reduce(0){|sum,current| sum + current} | |
puts (one_million_sum - one_million_minus_missing_sum) == missing ? "It works" : "Did not work" |
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
# first method | |
def enforce_utf8(from = nil) | |
begin | |
self.is_utf8? ? self : Iconv.iconv('utf8', from, self).first | |
rescue | |
converter = Iconv.new('UTF-8//IGNORE//TRANSLIT', 'ASCII//IGNORE//TRANSLIT') | |
converter.iconv(self).unpack('U*').select{ |cp| cp < 127 }.pack('U*') | |
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
Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-extracted-values, akamai-x-get-nonces, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-serial-no |
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
@MQC9056 @inventory @invalidation | |
Feature: Inventory Cache Invalidation | |
As a SonyStyle user | |
In order to place an order for a product | |
SonyStyle must display accurate inventory information. | |
# This is to make sure an invalidation is only trigged when a product becomes in stock or goes out of stock | |
# SPEC00090005226 = "Intel Core i7-2630QM quad-core processor (2.0GHz) with Turbo Boost up to 2.90GHz" | |
Scenario: US CTO component in stock changes quantity and remains in stock | |
Given we will receive a "GCTO" inventory feed |
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
# Add this to your .bashrc after loading RVM | |
# Example: | |
# [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* | |
# source $HOME/rvm_bash_prompt.sh | |
# Current RVM gemset for bash prompt | |
function __my_rvm_ruby_version { | |
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') | |
[ "$gemset" != "" ] && gemset="@$gemset" | |
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') |
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
/* | |
* Question: Create a data structure to represent polynomial addition and substraction | |
* Run the code online: http://ideone.com/s5qjU | |
*/ | |
import static org.junit.Assert.*; | |
import org.junit.Test; | |
import java.util.*; | |
public class PolynomialTest | |
{ |