Skip to content

Instantly share code, notes, and snippets.

View vndmtrx's full-sized avatar
🎲
Fazendo vários nadas

Eduardo N.S.R. vndmtrx

🎲
Fazendo vários nadas
View GitHub Profile
@vndmtrx
vndmtrx / epoll_ev_clienteconecta.c
Created August 21, 2012 20:35
Função ev_clienteconecta
static void ev_clienteconecta(int epoll, int sock) {
struct sockaddr in_addr;
socklen_t in_len;
int status, cliente;
char host[NI_MAXHOST], porta[NI_MAXSERV];
while (1) {
in_len = sizeof(in_addr);
cliente = accept(sock, &in_addr, &in_len);
if (cliente == -1) {
@vndmtrx
vndmtrx / epoll_ev_clientedadosdisp.c
Created August 21, 2012 20:36
Função ev_clientedadosdisp
static void ev_clientedadosdisp(int sock) {
int concluido = 0;
ssize_t qtd;
char buf[TAMBUFFER];
while (1) {
qtd = read(sock, buf, sizeof(buf));
if (qtd == -1) {
// Se o erro for EAGAIN significa que todos os dados foram lidos.
if (errno != EAGAIN) {
@vndmtrx
vndmtrx / cli_list.zsh
Created September 3, 2012 19:12
Retrieve list of connected clients and compare with dhcp list.
#!/usr/bin/env zsh
iw dev wlan0 station dump | grep -i Station | cut -d " " -f 2 | xargs -I % zsh -c "echo '%: '; grep -i % /etc/dhcpd.conf"
// MAYAN_COUNT_TO_JD -- Determina o dia do Calendário Juliano na Contagem Longa Maia
var MAYAN_COUNT_EPOCH = 584282.5;
function mayan_count_to_jd(baktun, katun, tun, uinal, kin) {
return MAYAN_COUNT_EPOCH +
(baktun * 144000) +
(katun * 7200) +
(tun * 360) +
(uinal * 20) +
@vndmtrx
vndmtrx / fizzbuzz.py
Created December 13, 2012 19:26
FizzBuzz using Coroutines
#Decorador de Função
def coroutine(func):
def start(*args,**kwargs):
cr = func(*args,**kwargs)
next(cr)
return cr
return start
# Source
def source_fizzbuzz(fim, target):
10 PRINT "Hello, world."
20 END
PROGRAM HELLO
WRITE (*,100)
STOP
100 FORMAT (' Hello, world. ' /)
END
program HelloWorld(output)
begin
WriteLn('Hello, world.');
end.
#include <GL/glut.h>
#define font GLUT_BITMAP_HELVETICA_18
#define tx "Hello, world."
void text(void)
{
char *p, tex[] = tx;
p = tex;
glColor3d(1.0, 1.0, 0.0);
glRasterPos2d(-.5, 0.);
(defun helloworld ()
(print "Hello, world.")
)