Skip to content

Instantly share code, notes, and snippets.

@matejb
matejb / pipe_executor.go
Created August 10, 2017 08:27
simple Go pipe executor
package main
import (
"bytes"
"fmt"
"log"
"os/exec"
"strings"
)
@nogweii
nogweii / gist:8278021
Last active November 25, 2017 06:34
PageKite configuration for running your own front-end (broken, sorta)
# /etc/pagekite/20_frontend.rc on kites.evaryont.me
# Front-end selection
#
# Front-ends accept incoming requests on your behalf and forward them to
# your PageKite, which in turn forwards them to the actual server.
# Running my own front-end!
isfrontend
@arielzn
arielzn / ssh_run.py
Last active December 12, 2017 06:40
Running commands with paramiko on remote hosts defined on ssh_config
#!/usr/bin/env python
import os
import paramiko
import argparse
import socket
import logging
def create_ssh_client(hostname):
@zhu327
zhu327 / structure.py
Last active April 4, 2018 08:04
data structure
# coding: utf-8
u"""
线性数据结构, 栈, 队列, deques, 容器结构, 数据项之间存在相对的位置
"""
class Stack(object):
u"""
栈 先进后出
@suziewong
suziewong / ssh.md
Last active April 27, 2018 02:14
SSH端口转发实验

通过本机的81号端口访问测试服务器89的我的私人apache目录(端口为11063)

使用本地转发,在本机上输入

ssh -L 81:210.32.200.89:11063 suzie@210.32.200.89

这时候打开浏览器,输入地址127.0.0.1:81 我同时也试验了

ssh -L 81:127.0.0.1:11063 suzie@210.32.200.89

ssh -L 81:localhost:11063 suzie@210.32.200.89

@ekimekim
ekimekim / escapes.py
Created May 29, 2013 05:56
A python library of constants and utility functions for using ANSI terminal escapes.
"""
A python library of constants and utility functions for using ANSI terminal escapes.
Example usage:
>>> import escapes as e
>>> print e.FORECOLOUR(e.RED) + "this is red" + e.UNFORMAT
"""
ESC = "\033" # escape character for terminal
CSI = ESC + "[" # Control Sequence Initiator
import base64
import datetime
import hashlib
import hmac
import io
import json
import mimetypes
import os
import uuid
from urllib.error import HTTPError, URLError
@Hackforid
Hackforid / base.py
Created May 13, 2015 08:25
Sqlalchemy use scoped_session in Tornado
# -*- coding: utf-8 -*-
import store
from tools.tor import ThreadRequestContext
class BaseHandler(RequestHandler):
def prepare(self):
store.db()
@oss6
oss6 / lcg.py
Created December 22, 2013 16:42
Python implementation of the LCG (Linear Congruential Generator) for generating pseudo-random numbers.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import random as rnd
import numpy as np
from PIL import Image
from itertools import cycle
def main():
@simon-weber
simon-weber / rchandler.py
Last active July 31, 2018 13:58
An example of using a StackContext to store request data globally in Tornado. See https://groups.google.com/d/msg/python-tornado/8izNLhYjyHw/TNKGa9fgvpUJ for motivation and further discussion.
import tornado
class RequestContextHandler(tornado.web.RequestHandler):
def _execute(self, transforms, *args, **kwargs):
# following the example of:
# https://github.com/bdarnell/tornado_tracing/blob/master/tornado_tracing/recording.py
global_data = {} # add whatever here, e.g. self.request