Skip to content

Instantly share code, notes, and snippets.

View dflima's full-sized avatar
📱
developing stuff

Danilo dflima

📱
developing stuff
View GitHub Profile
@dflima
dflima / canvas.html
Created October 17, 2012 19:54
Drawing a line between two clicked points
<html>
<head>
<script type="text/javascript">
window.onload = function() {
var clicks = 0;
var lastClick = [0, 0];
var canvas = document.getElementById('exemploCanvas');
canvas.addEventListener('click', draw, false);
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 / bubble.c
Created October 17, 2012 19:42
Bubble Sort using threads
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>
#define DIM 10
int a[DIM], swapped = 0;
pthread_t thread[DIM];
void v_initiate() {
@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 / find_and_copy.sh
Created July 5, 2017 15:55
Encontra todos os arquivos pertencentes ao usuário "d.lima", que tenham sido modificados nos últimos seis dias e copia, mantendo a estrutura de diretórios, para o diretório "/home/d.lima/xavier_files"
find /srv/dev_data/xavier/ -type f -user "d.lima" -mtime -6 -exec cp --parents --target-directory=/home/d.lima/xavier_files/ {} \;
[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