Skip to content

Instantly share code, notes, and snippets.

View FZambia's full-sized avatar

Alexander Emelin FZambia

View GitHub Profile
@vlasovskikh
vlasovskikh / tweetread.py
Created June 1, 2014 23:26
Actor-based CLI Twitter client example for using asyncio
# Copyright (c) 2014 Andrey Vlasovskikh
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@FZambia
FZambia / tunnel.md
Last active May 18, 2016 09:44
making local port available through port on another machine via SSH tunneling
  1. Add into /etc/ssh/sshd_config on remote machine (remote.example.com):
GatewayPorts yes
  1. Restart sshd:
/etc/init.d/sshd restart 
@pyos
pyos / ping.py
Last active November 16, 2021 15:31
import time
import random
import struct
import select
import socket
def chk(data):
x = sum(x << 8 if i % 2 else x for i, x in enumerate(data)) & 0xFFFFFFFF
x = (x >> 16) + (x & 0xFFFF)
@m0sth8
m0sth8 / jsonhelper.go
Created March 12, 2014 01:20
jsonhelper
// Example
package main;
import (
"jsonhelper"
"fmt"
)
func main(){
jsonValue := []interface {}{
# API authentication
from social.apps.django_app.utils import strategy
from rest_framework.authtoken.models import Token
from rest_framework.views import APIView
from rest_framework import parsers
from rest_framework import renderers
from rest_framework.authentication import get_authorization_header
from rest_framework.response import Response

mkdown

What is this?

Mkdown renders Markdown GitHub gists with alternative CSS. Use it to elegantly share gists written in Markdown.

How do I use this?

To create your own mkdown URL, append the gist ID in a URL of the form: http://mkdown.com/{GIST ID}. The gist ID is the string at the end of a gist URL.

@truetug
truetug / tornado_multiasynchttpclient_example.py
Created May 31, 2013 08:53
MD5 hash calculation of multiple simultaneous requests
#!/usr/bin/env python
# encoding: utf-8
import functools
import hashlib
import logging
import tornado.web
import tornado.gen
import tornado.httpclient
import tornado.ioloop
@klovadis
klovadis / gist:5170446
Created March 15, 2013 14:59
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
-- gets all fields from a hash as a dictionary
local hgetall = function (key)
local bulk = redis.call('HGETALL', key)
local result = {}
local nextkey
for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
else
result[nextkey] = v
@quiver
quiver / README.md
Last active April 3, 2024 15:47
Who says PostgreSQL can't Pub/Sub like Redis?

Pub/Sub pattern with PostgreSQL's LISTEN/NOTIFY command

This is a simple chat-like program using pub-sub pattern, backed by PostgreSQL's LISTEN/NOTIFY command.

Publish

publish message to foo channel from user nickname.

$ python pub.py foo nickname
PUBLISH to channel #foo
@alexjs
alexjs / cors-nginx.conf
Created November 28, 2012 22:42 — forked from michiel/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#