Skip to content

Instantly share code, notes, and snippets.

View mapix's full-sized avatar

mapix mapix

View GitHub Profile
#!/bin/bash
if [[ `uname -s` == 'Darwin' ]]; then
brew update
brew install libtool autoconf automake
else
sudo apt-get update
sudo apt-get install -y libtool autoconf automake uuid-dev git-core
fi
In [1]: import socket
In [2]: serversocket = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
In [3]: serversocket.bind(('0.0.0.0', 0))
In [4]: serversocket.
serversocket.accept serversocket.getsockname serversocket.recvfrom_into
serversocket.bind serversocket.getsockopt serversocket.send
<style>
.ExternalClass{
width: 100%;
}
</style>
<div align="center" style="width:100%;background-color:#EDEDED;color:#999">
<table style="font-size:12px;color:#999;width:690px;height:35px">
<tr>
<td style="text-align: left">
邮件显示有问题? 查看
# -*- coding: utf-8 -*-
import requests
from urlparse import urlparse
from flask import Flask
from flask import Response
from flask import request
from flask import stream_with_context
#! python
'''
pip install pyobjc-core
pip install pyobjc-framework-QTKit
pip install pyautogui
'''
import pyautogui, sys
print('Press Ctrl-C to quit.')
try:
import sys
while 1:
print str(i),
print '\b'*(len(str(i)) + 2),
i += 1
sys.stdout.flush()

Authentication

.netrc (for svn)

  1. Create ~/.netrc with your WatIAM credentials to log into the SVN server

     machine ecesvn.uwaterloo.ca login <USERNAME> password <PASSWORD>
    
  2. Set the correct permissions on ~/.netrc (Note: This won't save you from untrusted sysadmins on that box.)

@mapix
mapix / pagination.py
Created July 11, 2014 02:37
Python Pagination
# -*- coding: utf-8 -*-
from math import ceil
from flask import request
from werkzeug.utils import cached_property
class Pagination(object):
def __init__(self, page, per_page, total, max_label_count=16):
#!/usr/bin/env python
import sys, os, time, atexit
from signal import SIGTERM
class Daemon:
"""
A generic daemon class.
Usage: subclass the Daemon class and override the run() method
@mapix
mapix / python_instance_principle.py
Last active March 30, 2018 07:57
Python Instance Principle
class MetaClass(type):
def __new__(mcls, classname, baseclasses, attrs):
print '\nMetaClass.__new__ ------> '
print '-' * 40
print '\tmcls: %s:%s' % (mcls, type(mcls))
print '\tclassname: %s:%s' % (classname, type(classname))
print '\tbaseclasses: %s:%s' % (baseclasses, type(baseclasses))
print '\tattrs: %s:%s' % (attrs, type(attrs))
return type.__new__(mcls, classname, baseclasses, attrs)