🤹♂️
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 sys, collections | |
cases = int(sys.stdin.readline().strip()) | |
for case in range(1, cases + 1): | |
candidate_min, candidate_max = map(int, sys.stdin.readline().strip().split()) | |
# Python is good at sparse dictionaries, so use a bubbling | |
# Sieve of Erastothenes to be memory efficient and fairly | |
# computationally efficient | |
composites = collections.defaultdict(list) | |
for candidate in range(2, candidate_max + 1): | |
if candidate not in composites: |
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
#!/usr/bin/env python3 | |
import os, sys | |
import xmlrpc.client | |
rpc_key = '...' # replace with your RPC Key from http://upcdatabase.com/user | |
server = xmlrpc.client.ServerProxy('http://www.upcdatabase.com/xmlrpc') | |
lookup_keys = {12: 'upc', 13: 'ean'} |
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 AdminController < ApplicationController | |
layout :admin | |
def index | |
render :dashboard | |
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
// Try to be as sensible as possible about parsing durations | |
function parseDuration(duration) { | |
// .75 | |
if (match = /^\.\d+$/.exec(duration)) { | |
return parseFloat("0" + match[0]) * 3600; | |
// 4 or 11.75 | |
} else if (match = /^\d+(?:\.\d+)?$/.exec(duration)) { | |
return parseFloat(match[0]) * 3600; | |
// 01:34 | |
} else if (match = /^(\d+):(\d+)$/.exec(duration)) { |
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 'rack' | |
use Rack::ContentLength | |
use Rack::ContentType | |
run proc { |env| [200, {}, '<p>First application</p><p><a href="/bar">Go to Second Application</a></p>'] } |
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
Around do |scenario, block| | |
# We can't use .begin/rollback_db_transaction as they don't do the | |
# savepoint emulation on MySQL, it's all encapsulated in | |
# .transaction | |
result = nil | |
ActiveRecord::Base.transaction(:requires_new => true) do | |
result = block.call | |
raise ActiveRecord::Rollback | |
end | |
result |
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
Around do |scenario, block| | |
# We can't use .begin/rollback_db_transaction as they don't do the | |
# savepoint emulation on MySQL, it's all encapsulated in | |
# .transaction | |
result = nil | |
ActiveRecord::Base.transaction(:requires_new => true) do | |
begin | |
result = block.call | |
ensure | |
raise ActiveRecord::Rollback |
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 destroy | |
authorize! :destroy, @health_professional | |
@health_professional.destroy | |
respond_with :manage, @health_professional | |
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 'headless' | |
# Wrap in headless to make sure we have an xvfb | |
AfterConfiguration do | |
# Base display number on current PID | |
headless = Headless.new :display => Process.pid | |
headless.start | |
at_exit do |
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
config.generators.stylesheet_engine = :sass |