Skip to content

Instantly share code, notes, and snippets.

View tiagodavi's full-sized avatar
🏠
Working from home

Tiago Davi tiagodavi

🏠
Working from home
View GitHub Profile
@tiagodavi
tiagodavi / solution.py
Last active December 28, 2023 20:46
count total of subsequent string in a row
# The goal is to count the frequency of subsequent strings in a row.
def count_subsequent_str(str):
str = str.lower()
temp = {}
for i in range(len(str) - 1):
if not str[i] in temp:
temp[str[i]] = 0
if str[i] == str[i+1] and temp[str[i]] < 1:
temp[str[i]] += 2
defmodule NxDiabetes do
@moduledoc """
Documentation for `NxDiabetes`.
DataSet:
https://www.kaggle.com/uciml/pima-indians-diabetes-database
"""
alias NimbleCSV.RFC4180, as: CSV
require Axon
@tiagodavi
tiagodavi / Divisible Sum Pairs.clj
Created July 30, 2016 17:29
Divisible Sum Pairs.clj
(defn string-to-vector [x]
(clojure.string/split x #" "))
(defn to-int [x]
(Integer/parseInt x))
(defn divisible? [i j k]
(let [i (to-int i)
j (to-int j)
k (to-int k)
@tiagodavi
tiagodavi / Compare the Triplets.clj
Created July 25, 2016 17:38
Compare the Triplets.clj
(defn to-int [x]
(Integer/parseInt x))
(defn string-to-vector [x]
(clojure.string/split x #" "))
(def alice-points (atom 0))
(def bob-points (atom 0))
(defn counter [points]
(defn to-int [x] (Integer/parseInt x) )
(defn string-to-vector [x] (clojure.string/split x #" "))
(def size (read-line))
(def items (read-line))
(println (reduce + (map to-int (string-to-vector items))))
@tiagodavi
tiagodavi / multiple_upload.php
Created October 26, 2015 22:50
It does multiple upload with php
<?php
//phpinfo();
$multiple_upload = function (array $inputs){
$result = array();
if($inputs){
foreach($inputs as $key => $index){
if(is_array($index)){
foreach($index as $i => $value){
$result[$i][$key] = $value;
<?php
//file upload.php
$pic = $_FILES['pic'];
echo '<pre>';
print_r($pic);
?>
@tiagodavi
tiagodavi / chain.exs
Last active October 20, 2015 20:17
A code that creates n processes
# How does it work?
# $ elixir -r chain.exs -e "Chain.run(1000)" to have one thousand processes.
defmodule Chain do
def counter(next_pid) do
receive do
n -> send next_pid, n + 1
end
end
@tiagodavi
tiagodavi / happy_number_spec.rb
Last active August 29, 2015 14:18
BDD with Happy Numbers
describe HappyNumber do
it "Is possible to chek if a number is happy?" do
happy_number = HappyNumber.new
expect(happy_number.happy?(7)).to be true
end
end
#happy_number.rb
class HappyNumber
def happy?(number)
@tiagodavi
tiagodavi / resolve-nodejs.sh
Created March 31, 2015 14:51
Resolve nodejs npm ERR!
npm config set registry https://registry.npmjs.org/