Skip to content

Instantly share code, notes, and snippets.

CC=cc
LIBS=-lncurses -lm
CFLAGS=-Wall -O3
SRC=$(wildcard *.c)
OBJ=$(SRC:.c=.o)
TARGET=mandelbrot
all: ${OBJ}
${CC} $(CFLAGS) $(LIBS) $^ -o ${TARGET}
@SakuraSa
SakuraSa / flask_stream_example.py
Created June 8, 2020 09:11
flask stream example
# encoding: utf-8
"""
python flask_stream_example.py
open http://localhost:9999/stream
"""
from flask import stream_with_context, request, Response, Flask
import time
@SakuraSa
SakuraSa / dataParser.py
Last active December 30, 2017 09:28
dataParser.py
# coding: utf-8
import re
from collections import OrderedDict
from pprint import pprint
KEY0 = re.compile(r'学科代码及名称:\d+\s+(\w+)')
KEY1 = re.compile(r'\n([A-C][\+-]?)')
DATA = re.compile(r'(\d+)\s+(\w+)')
package com.jd.testGround;
import com.google.common.base.Joiner;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@SakuraSa
SakuraSa / tree_width.py
Last active October 20, 2015 13:03
get tree width
class Node:
left = right = None
def node_only(iterable_nodes):
return filter(bool, iterable_nodes)
def iter_layer(layer):
layer = node_only(layer)
while layer:
yield layer
@SakuraSa
SakuraSa / BetterGen
Created May 30, 2015 07:29
BetterGen with "has_next" property
class BetterGen(object):
"""
BetterGen
"""
def __init__(self, gen):
self.gen = gen
self._next = None
self._stoped = False
self.try_next()
115.221.60.130 - - [21/Mar/2015:01:59:32 +0800] "GET / HTTP/1.0" 200 1763 "-" "-"
115.221.60.130 - - [21/Mar/2015:01:59:42 +0800] "HEAD / HTTP/1.0" 405 0 "-" "-"
115.221.60.130 - - [21/Mar/2015:01:59:47 +0800] "TRACE HTTP://localhost HTTP/1.0" 405 172 "-" "-"
115.221.60.130 - - [21/Mar/2015:01:59:53 +0800] "TRACE / HTTP/1.0" 405 172 "-" "-"
115.221.60.130 - - [21/Mar/2015:02:00:00 +0800] "\x80\x80\x01\x03\x01\x00W\x00\x00\x00 \x00\x00\x16\x00\x00\x13\x00\x00" 400 172 "-" "-"
115.221.60.130 - - [21/Mar/2015:02:00:06 +0800] "\x03\x00\x00\x0B\x06\xE0\x00\x00\x00\x00\x00" 400 172 "-" "-"
115.221.60.130 - - [21/Mar/2015:02:00:18 +0800] "y\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00 CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\x00\x00!\x00\x01" 400 172 "-" "-"
115.221.60.130 - - [21/Mar/2015:02:00:30 +0800] "\x81\x00\x00D EBENEBFACACACACACACACACACACACACA\x00 EBENEBFACACACACACACACACACACACACA\x00" 400 172 "-" "-"
115.221.60.130 - - [21/Mar/2015:02:00:43 +0800] "\x00\x00\x00\x85\xFFSMBr\x00\x00\x00\x00\x18S\xC8\x00\x00\x00\x00\x0
@SakuraSa
SakuraSa / can_it_works.py
Created September 23, 2014 14:14
can_it_works?
from requests import session
from bs4 import BeautifulSoup as bs
USER = 'USER'
PASSWORD = 'PASSWORD'
URL1 = 'https://github.com/login'
URL2 = 'https://github.com/session'
with session() as s:
@SakuraSa
SakuraSa / Github_login.py
Created September 23, 2014 12:58
Github_login.py
#!/usr/bin/env python
#coding=utf-8
import requests
from BeautifulSoup import BeautifulSoup
username = 'MY GITHUB ACCOUNT'
password = 'MY GITHUB PASSWORD'
session = requests.Session()
@SakuraSa
SakuraSa / Github_login.py
Last active June 7, 2017 13:15
Github_login.py
#!/usr/bin/env python
#coding=utf-8
import requests
from BeautifulSoup import BeautifulSoup
username = 'MY GITHUB ACCOUNT'
password = 'MY GITHUB PASSWORD'
session = requests.Session()