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 / bootstrap.php
Created October 17, 2012 19:34
Simple autoload function in PHP
<?php
define('RAIZ_DA_APP', dirname(__FILE__));
define('LIB', RAIZ_DA_APP.'/lib');
function meuAutoload($classe){
$d = LIB;
include "{$d}/{$classe}.php";
}
spl_autoload_register('meuAutoload');
@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 / 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);
@dflima
dflima / client.c
Created November 5, 2012 22:37
Aula de Sockets (Paralelo) - Client
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#define PORTA 8880
int e_socket, conexao;
@dflima
dflima / server.c
Created November 5, 2012 22:38
Aula de Sockets (Paralelo) - Server
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#define PORTA 8880
#define MAXBUF 20
#define MAXCONECT 5
@dflima
dflima / shell.sh
Created November 5, 2012 22:38
shell script
#!/bin/bash
gcc server.c -o server -lpthread
gcc client.c -o client -lpthread
@dflima
dflima / cliente_concorrente.c
Created November 8, 2012 23:58
Aula de Sockets (Concorrente) - Cliente
#include<sys/types.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<stdio.h>
#include<stdlib.h>
#define PORTA 8888
main(){
int e_socket, conexao;
@dflima
dflima / servidor_concorrente.c
Created November 8, 2012 23:58
Aula de Sockets (Concorrente) - Servidor
#include<sys/types.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<stdio.h>
#include<stdlib.h>
#define PORTA 8888
#define MAXBUF 20
#define MAXCONECT 5
@dflima
dflima / kill.sql
Created November 12, 2012 18:37
Matando processos no SQL Server.
/*
* Como matar processos no SQL Server
* e ter exclusividade na base
*
* Fonte: http://sqldicas.com.br/dicas/matando-processos-no-sql/
*/
declare @spid int
declare @db_name varchar(100)
set @db_name = 'NomeDaBase' -- coloque o nome da base aqui
@dflima
dflima / MultSet.hs
Created November 12, 2012 19:17
Transforming a MulSet data type to an array using Haskell
data MultSet = Nil | MS Int Int (MultSet)
deriving Show
ins k (Nil) = MS k 1 (Nil)
ins k (MS e n ms)
| k == e = MS e (n+1) ms
| otherwise = MS e n (ins k ms)
ltm [] = Nil
ltm (x:xs) = ins x (ltm xs)