Skip to content

Instantly share code, notes, and snippets.

View dflima's full-sized avatar
📱
developing stuff

Danilo dflima

📱
developing stuff
View GitHub Profile
records = [
%{"data" => "2023-07-13", "qtd" => 12},
%{"data" => "2023-07-14", "qtd" => 30},
%{"data" => "2023-07-13", "qtd" => 4},
%{"data" => "2023-07-14", "qtd" => 98},
%{"data" => "2023-07-12", "qtd" => 4},
%{"data" => "2023-07-12", "qtd" => 8},
%{"data" => "2023-07-12", "qtd" => 31},
%{"data" => "2023-07-15", "qtd" => 74},
%{"data" => "2023-07-13", "qtd" => 12},
@dflima
dflima / index.html
Created June 21, 2023 23:34
International Telephone Input - BOOTSTRAP INPUT GROUP
<h1>International Telephone Input - BOOTSTRAP INPUT GROUP</h1>
<form>
<div class="input-group">
<input type="tel" class="form-control">
<span class="input-group-addon">Tel</span>
</div>
<br>
<div class="input-group">
<input type="tel" class="form-control">
<span class="input-group-addon">Tel</span>
@dflima
dflima / Dockerfile
Created June 24, 2019 18:31
Dockerfile for Memcached
# Memcached Dockerfile
#
# VERSION 0.0.1
FROM debian:jessie
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r memcache && useradd -r -g memcache memcache
RUN apt-get update && apt-get install -y libevent-2.0-5 && rm -rf /var/lib/apt/lists/*
@dflima
dflima / calculator.rb
Created January 16, 2019 20:44
[XP Training] Pair programming calculator problem
class Calculator
def calculate(input)
splited = split_string(input)
mapped = splited.map(&:to_i)
if (input.include?('+'))
return mapped.reduce(:+)
elsif (input.include?('-'))
return mapped.reduce(:-)
@dflima
dflima / Block.java
Created December 5, 2018 15:43
Blockchain implementation in Java
import java.util.Date;
public class Block {
public String hash;
public String previousHash;
private String data;
private long timestamp;
public Block(String data, String previousHash) {
this.data = data;
@dflima
dflima / anagram.ex
Last active December 5, 2018 15:32
That’s all the Elixir code you need to find an anagram of a word.
defmodule Anagram do
@moduledoc """
iex(1) > Anagram.match("dog", ["apple", "cow", "god"])
["god"]
"""
@spec match(String.t(), list()) :: list()
def match(base, candidates) when is_list(candidates) do
base_fingerprint = fingerprint(base)
@dflima
dflima / fibonacci.ex
Last active July 26, 2018 17:41
using Tail Call Optimization pattern
defmodule Fibonacci do
def start(n) do
start = :os.system_time(:seconds)
fibonacciNumber = getNumber(n)
finish = :os.system_time(:seconds)
totalTime = finish - start
IO.puts("The fibonacci number was #{fibonacciNumber}")
IO.puts("Fibonacci for number placed #{n} finished in #{totalTime} seconds!")
end
[alias]
foo="!f() { echo "begin arg=$1/$2/end"; }; f"
# Short for status
st = status
# View the current working tree status using short format
s = status -s
<?php
$handle = fopen ("php://stdin", "r");
function timeConversion($s) {
// Complete this function
$dateTime = DateTime::createFromFormat('h:i:sa', $s);
return $dateTime->format('H:i:s');
}
<?php
$handle = fopen ("php://stdin", "r");
function birthdayCakeCandles($n, $ar) {
// Complete this function
$a = array_count_values($ar);
rsort($a, SORT_NUMERIC);
return reset($a);
}