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
iptables -A OUTPUT -t mangle -p tcp --dport 22 -j TOS --set-tos 0x00 |
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 'httparty' | |
fetch = -> (url) { | |
HTTParty.get(url, headers: { "Accept" => "application/json"}) | |
} | |
response = fetch.("http://letsrevolutionizetesting.com/challenge.json") | |
begin | |
next_url = response["follow"] |
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
defmodule UniquePairs do | |
def hundreds(numbers) do | |
numbers | |
|> combinations | |
|> is_hundred | |
|> sort_pairs | |
|> Enum.uniq | |
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
class Parent | |
def initialize(name) | |
@name = name | |
end | |
private | |
attr_accessor :name | |
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
- Jester King | |
- Black Metal Farmhouse Imperial Stout | |
- Whatever Farmhouse and Wild Ales they have out | |
- Anything else you see from them, apparently | |
- Austin Beerworks | |
- Fire Eagle IPA | |
- Heavy Machinery Double IPA | |
- Peacemaker Pale Ale | |
- Blackthunder Schwarzbier |
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
credit_card = ActiveMerchant::Billing::CreditCard.new(cc_number, cc_info_hash) | |
gateway = ActiveMerchant::Billing::CardinalCentinelGateway.new( | |
ProcessorId: '123', | |
MerchantId: '456', | |
TransactionPwd: 'p4ssw0rd' | |
) | |
lookup_response = gateway.authorize(amount, credit_card) | |
if lookup_response.enrolled? |
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 by_path(ancestry) do | |
Enum.reduce(ancestry, App.Node, fn (ancestor, query) -> | |
query | |
|> join(:inner, [n], n1 in App.Node, n1.id == n.parent_id) | |
|> where([n], n.key == ^ancestor) # This is where I'm stuck, all the where's are n0."key", see line 14 | |
end) | |
end | |
# Here is the resulting SQL: | |
SELECT n0."id", n0."key", n0."project_id", n0."type", n0."parent_id" |
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
defmodule ListOp do | |
def flatten([head | tail]), do: flatten(tail, [head]) | |
def flatten([], acc), do: Enum.reverse(acc) | |
def flatten([ [head | []] | tail], acc), do: flatten(tail, [head | acc]) | |
def flatten([ [head | rest] | tail], acc), do: flatten(flatten([rest | tail], [head | acc])) | |
def flatten([head | tail], acc), do: flatten(tail, [head | acc]) | |
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
def loop(model, models) do | |
task_sup = Process.whereis(:worker_supervisor) | |
Stream.resource( | |
fn -> {model, 0} end, | |
&func_that_gets_data/1, | |
fn(_) -> :ok end | |
) | |
|> Stream.chunk(20) | |
|> Stream.map(fn(ids) -> Task.Supervisor.async(task_sup, Worker, :sanitize, [model, ids]) 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
def count_between arr, lower, upper | |
return 0 if arr.length == 0 || lower > upper | |
return arr.length if lower == upper | |
range = (lower..upper).to_a | |
arr.select { |value| range.include?(value) }.length | |
end |
OlderNewer