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
| let rec to_binary(value: UInt32)= | |
| if value < 2u then | |
| value.ToString() | |
| else | |
| let divisor = value/2u | |
| let remainder = (value % 2u).ToString() | |
| to_binary(divisor) + remainder |
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
| defmodule Fibonacci do | |
| def calc(0), do: 1 | |
| def calc(1), do: 1 | |
| def calc(n) when n > 0, do: calc(n-2) + calc(n-1) | |
| 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
| headers = [ | |
| {"Content-Type", "application/x-www-form-urlencoded"}, | |
| {"Accept", "text/html"} | |
| ] | |
| encoded_text = URI.encode_www_form(text) | |
| body = "text=#{encoded_text}" | |
| case HTTPoison.post(url, body, headers) do | |
| {:ok, %HTTPoison.Response{status_code: 200, body: body}} -> |
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
| case HTTPoison.post(url, body, headers) do | |
| {:ok, %HTTPoison.Response{status_code: 200, body: body}} -> | |
| body | |
| {:ok, %HTTPoison.Response{status_code: 404}} -> | |
| "Not found :(" | |
| {:error, %HTTPoison.Error{reason: reason}} -> | |
| reason | |
| 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
| # coding=utf-8 | |
| """ | |
| Convert a file from one encoder to another | |
| usage: python file_encoder.py 'source encode', 'target encode', | |
| 'source file', 'target' | |
| example: python file_encoder.py 'iso8859-1', 'utf-8', 'file.html', | |
| 'file-utf8.html' | |
| """ | |
| import sys |
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
| var exec = require('child_process').exec; | |
| var child = exec("echo 'teste'", | |
| function (error, stdout, stderr) { | |
| if(stdout!==''){ | |
| console.log('---------stdout: ---------\n' + stdout); | |
| } | |
| if(stderr!==''){ | |
| console.log('---------stderr: ---------\n' + stderr); |
NewerOlder