This file contains hidden or 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
| # totally untested bloo.tk in 5 lines, one of which is a comment ;) | |
| require 'json', 'sinatra' | |
| get '/*' do | |
| redirect JSON.parse(`curl http://api.duckduckgo.com/?q=#{params[:splat].join(' ')}&format=json`)['Results']['FirstURL'] | |
| end |
This file contains hidden or 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 'mechanize' | |
| module Gangsta | |
| def self.to_gangsta(english) | |
| agent = Mechanize.new | |
| page = agent.get "http://gizoogle.net/textilizer.php" | |
| search_form = page.form_with :name => "query" | |
| search_form.field_with(:name => "translatetext").value = english | |
| search_results = agent.submit search_form |
This file contains hidden or 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
| arr2_pos = 0 | |
| product = 0 | |
| for each thing1 in arr1: | |
| while arr2[arr2_pos][0] <= thing1[0]: | |
| arr2_pos++ | |
| if arr2[arr2_pos][0] == thing1[0]: | |
| product += arr2[arr2_pos][1] * thing1[1] | |
| return product |
This file contains hidden or 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 C<T> {} | |
| protocol P { | |
| typealias E : C<Self> | |
| } | |
| final class A : P { | |
| typealias E = C<A> | |
| } |
This file contains hidden or 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 C<T> {} | |
| protocol P { | |
| typealias E : C<Self> | |
| } | |
| class A : P { | |
| typealias E = C<A> | |
| } |
This file contains hidden or 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 Game | |
| @XMax: 25 | |
| @YMax: 15 | |
| @DotsPerPlayer: 2 | |
| @FunctionAnimationSpeed: 0.005 # graph units per ms | |
| @DotRadius: 1 | |
| @TurnTime: 60000 # ms | |
| @ObstacleCount: 10 | |
| @ObstacleRadiusMin: 0 | |
| @ObstacleRadiusMax: 5 |
This file contains hidden or 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
| Moves = | |
| start: () -> | |
| {type: 'start'} | |
| class Players | |
| constructor: (@game) -> | |
| @teams: [ | |
| active: true | |
| players: [] |
This file contains hidden or 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 Node(object): | |
| def __init__(self, _children): | |
| self.memo = None | |
| self.children = _children | |
| dest = Node([]) | |
| source = Node([ | |
| dest, # source -> dest | |
| Node([dest]), # source -> intermediate -> dest | |
| Node([Node([dest])]), # source -> a -> b -> dest |
This file contains hidden or 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
| # Balanced binary tree of height 2. Boring, I know... | |
| node_count = 7 | |
| edges = [ | |
| (0,1), | |
| (0,2), | |
| (1,3), | |
| (1,4), | |
| (2,5), | |
| (2,6) | |
| ] |
This file contains hidden or 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
| # Author: Ishaan Gulrajani | |
| # License: BSD 3-clause | |
| import numpy | |
| import theano | |
| import theano.tensor as T | |
| # log(0) = -infinity, but this leads to | |
| # NaN errors in log_add and elsewhere, | |
| # so we'll just use a large negative value. |
OlderNewer