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' | |
class Github | |
include HTTParty | |
base_uri "https://api.github.com" | |
BaseDirectory = "/Users/ugorelik/programming/repos" | |
def initialize(u, p) | |
@auth = { username: u, password: p} | |
load_bitbucket_repos |
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 Tax do | |
def get_tax_rates do | |
[ NC: 0.075, TX: 0.08 ] | |
end | |
def get_orders do | |
[ | |
[ id: 123, ship_to: :NC, net_amount: 100.00 ], | |
[ id: 124, ship_to: :OK, net_amount: 35.50 ], | |
[ id: 125, ship_to: :TX, net_amount: 24.00 ], | |
[ id: 126, ship_to: :TX, net_amount: 44.80 ], |
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 Test do | |
def create(conn, params) do | |
params | |
|> do_register # do business logic | |
|> format_response(conn) # create the message | |
|> render_json # just render it, simple, elegant | |
end | |
# toda funcao no elixir retorna alguma coisa, não existe `void` | |
defp do_register(params) 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
(defun safadao () | |
(interactive) ;; interactive interpreter | |
(let (birthdate) ;; create variable birthdate, it will be avaliable for nested stuff | |
(progn (setq birthdate (read-no-blanks-input "digite sua data de nascimento: "))) ;; set birthdate to whatever user inputs | |
(if (and (< 7 (length birthdate)) | |
(> 9 (length birthdate))) | |
(let ((sum 0) list day month year safadeza) | |
(progn | |
(setq list (split-string birthdate "/")) |
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
# encoding: UTF-8 | |
require 'rubygems' | |
require 'csv' | |
require 'geocoder' | |
ips = CSV.read('ip.csv') | |
total = ips.length | |
decoded_ips = [] |
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
/* | |
* DO NOT COMPILE AND RUN UNLESS YOU KNOW WHAT YOU ARE DOING. | |
* This is a 29 byte C code that compiles to a 17,179,875,837 byte (16 GB) executable. | |
* Author: Digital Trauma (codegolf.stackexchange.com/users/11259/digital-trauma) | |
* This defines the main function as a large array and initialises its first element. | |
* This causes GCC to store the entire array in the resulting executable. | |
* Because this array is bigger than 2GB, | |
* we need to provide the -mcmodel=medium flag to GCC. | |
* The extra 15 bytes are included in the score, as per the rules. | |
* Compile with: |
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 WordFreq.Parser do | |
def work do | |
read_file | |
|> to_list | |
|> group | |
|> transform | |
|> Enum.take(10) | |
end | |
@doc """ |
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 Worker do | |
def start do | |
pid = spawn(__MODULE__, :loop, []) | |
send(server_pid, {:request, pid}) | |
pid | |
end | |
def server_pid do | |
:global.whereis_name("server") | |
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
defmodule MyApp.DistributionManager do | |
use GenServer | |
require Logger | |
@app Mix.Project.config[:app] | |
def start_link(iface) do | |
GenServer.start_link(__MODULE__, iface) | |
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
#include <iostream> | |
#include <cmath> | |
#include <climits> | |
using namespace std; | |
const int MAX_N = 510; | |
const int MAX_K = 510; | |
int N, K; |
OlderNewer