Skip to content

Instantly share code, notes, and snippets.

@Ilgrim
Ilgrim / Makefile
Created August 14, 2018 20:07 — forked from xuhdev/Makefile
Makefile template for shared library
# Makefile template for shared library
CC = gcc # C compiler
CFLAGS = -fPIC -Wall -Wextra -O2 -g # C flags
LDFLAGS = -shared # linking flags
RM = rm -f # rm command
TARGET_LIB = libtarget.so # target lib
SRCS = main.c src1.c src2.c # source files
OBJS = $(SRCS:.c=.o)
# coding=utf-8
"""
LICENSE http://www.apache.org/licenses/LICENSE-2.0
"""
import datetime
import sys
import time
import threading
import traceback
import SocketServer
@Ilgrim
Ilgrim / dns.c
Created August 16, 2018 23:09 — forked from fffaraz/dns.c
DNS Query Code in C with linux sockets
//DNS Query Program on Linux
//Author : Silver Moon ([email protected])
//Dated : 29/4/2009
//Header Files
#include<stdio.h> //printf
#include<string.h> //strlen
#include<stdlib.h> //malloc
#include<sys/socket.h> //you know what this is for
#include<arpa/inet.h> //inet_addr , inet_ntoa , ntohs etc
@Ilgrim
Ilgrim / composer.json
Created September 12, 2018 16:48 — forked from raulghm/composer.json
Slim Framework + Eloquent ORM [Ultimate Solution] Thanks to: https://github.com/pyrocms/pyrocms/commit/7b7d92944f5de88fef9ec0b744289b924394a12e
{
"require": {
"slim/slim": "2.*",
"illuminate/database": "*",
"dhorrigan/capsule": "*"
}
}
@Ilgrim
Ilgrim / README.md
Created October 5, 2018 19:30 — forked from vitiral/README.md
ZMQ python communications

ZMQ python

Demonstrates some simple zmq communication

Similar to this example but usable more generally.

Quoting http://zeromq.org/area:faq:

Can I subscribe to messages using regex or wildcards?

@Ilgrim
Ilgrim / django_task_queue.md
Created October 12, 2018 17:00 — forked from tapanpandita/django_task_queue.md
Task queuing in Django with ZeroMQ

Task queuing in Django with ZeroMQ

Introduction

Here at Glitterbug Tech, Django is the lifeline of everything we make and we are big fans! Django doesn't get in the way and lets us write the language we love, python, while providing an amazing set of tools that makes creating web applications fast and fun. But, as you know, code is executed synchronously before you can send back a response. Which means when you are generating that report from your database which has a million rows, your client has to wait for a response while your application huffs and puffs trying to get everything ready (Unless he times out, in which case you receive angry calls while you try to explain what "502 Bad Gateway" means). Sometimes you just want to make your site more responsive by pushing time consuming tasks in the background ("Your comment has been posted!" while a zmq process works in the backend adding it to your db/caching layer/pushing it to followers/creating rainbows). Wha

@Ilgrim
Ilgrim / zmq_websocket_gateway.py
Created October 13, 2018 22:37 — forked from alco/zmq_websocket_gateway.py
A ZeroMQ - WebSocket gateway
# coding=utf8
# Copyright (C) 2011 Saúl Ibarra Corretgé <[email protected]>
#
import hashlib
import os
import re
import socket
import struct
@Ilgrim
Ilgrim / client.cc
Created October 13, 2018 23:03 — forked from alexgartrell/client.cc
Simple ZeroMQ Router Demo
#include <stdio.h>
#include <stdlib.h>
#include <czmq.h>
#include <zmq.h>
int main(int argc, char *argv[]) {
zctx_t *ctx = zctx_new();
void *dealer = zsocket_new(ctx, ZMQ_DEALER);
zsocket_connect(dealer, "tcp://localhost:%d", 2222);
@Ilgrim
Ilgrim / router.py
Created October 13, 2018 23:21 — forked from anopheles/router.py
Router Dealer example with bidirectional communication
# encoding: utf-8
import zmq
from collections import defaultdict
context = zmq.Context()
client = context.socket(zmq.ROUTER)
client.bind("tcp://*:5556")
poll = zmq.Poller()