Skip to content

Instantly share code, notes, and snippets.

View atupal's full-sized avatar

kangle yu atupal

View GitHub Profile
import re
import json
import urllib
import base64
import hashlib
import requests
WBCLIENT = 'ssologin.js(v.1.3.18)'
sha1 = lambda x: hashlib.sha1(x).hexdigest()
#!/usr/bin/env python
from __future__ import unicode_literals
from __future__ import print_function
from argparse import ArgumentParser
import json
import re
import sys
try:
#Py3
Nested X session
To run a nested session of another desktop environment:
/usr/bin/Xnest :1 -geometry 1024x768+0+0 -ac -name Windowmaker & wmaker -display :1
Virtual X session
To start another X session in, for example, Ctrl+Alt+F8, you need to type this on a console:
xinit /path/to/wm -- :1
挂载windos上的共享目录
//kmp失效函数
int* go(char *module)
{
int m = strlen(module);
int i;
int *p = (int *) malloc (sizeof(int) * m);
memset(p, 0, sizeof(p));
p[0] = -1;
int j = -1;
@atupal
atupal / layout.html
Created April 8, 2013 17:08
two way to use mark down in python
first way:
{{ content }}
second way:
{% filter markdown %}
Your Markdown
=============
{% endfilter %}
<style type="text/css">
.linebr {
clear: both; /* 清除左右浮动 */
width: 100px; /* 必须定义宽度 */
word-break: break-word; /* 文本行的任意字内断开 */
/*
A. Greg and Array
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Greg has an array a = a1, a2, ..., an and m operations. Each operation looks as: li, ri, di, (1 ≤ li ≤ ri ≤ n). To apply operation i to the array means to increase all array elements with numbers li, li + 1, ..., ri by value di.
Greg wrote down k queries on a piece of paper. Each query has the following form: xi, yi, (1 ≤ xi ≤ yi ≤ m). That means that one should apply operations with numbers xi, xi + 1, ..., yi to the array.
/**
* Optimized Code For Quantizing Colors to xterm256
*
* These functions are equivalent to the ones found in xterm256.py but
* orders of a magnitude faster and should compile quickly (fractions
* of a second) on most systems with very little risk of
* complications.
*
* Color quantization is very complex. This works by treating RGB
* values as 3D euclidean space and brute-force searching for the
import Queue
import threading
import urllib2
import time
from BeautifulSoup import BeautifulSoup
hosts = ["http://yahoo.com", "http://google.com", "http://amazon.com",
"http://ibm.com", "http://apple.com"]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
const int maxn = 50001;
int n;
double x[maxn];
double y[maxn];