This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import urllib,chardet,re | |
from sgmllib import SGMLParser | |
from BeautifulSoup import BeautifulSoup | |
'''爬取网页新闻的黑标题下的网页正文部分,保存在txt文档里 | |
以黑标题的名字作为txt文档的名字 | |
这个黑标题不是网页打开之后的正文标题 | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define PRIME_SIZE 100000 | |
int main(void) | |
{ | |
int i,j=0,k; | |
int a[PRIME_SIZE]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_abundant(n): | |
max_divisor = int(n / 2) + 1 | |
sum = 0 | |
for x in range(1, max_divisor): | |
if n % x == 0: | |
sum += x | |
return sum > n | |
abundants = list(x for x in range(1, 28123) if is_abundant(x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' An enriched dictionary that holds a mapping from keys to scores ''' | |
from bisect import bisect_left, insort_left | |
import UserDict | |
class Ratings(UserDict.DictMixin, dict): | |
""" class Ratings is mostly like a dictionary, with extra features: the | |
value corresponding to each key is the 'score' for that key, and all | |
keys are ranked in terms their scores. Values must be comparable; keys, | |
as well as being hashable, must be comparable if any two keys may ever | |
have the same corresponding value (i.e., may be "tied" on score). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 –*- | |
''' 对于turtle类的一些封装方法,包括画正多边形,正多角形和五星红旗。''' | |
__author__ = 'Hu Wenchao' | |
import turtle | |
import math | |
def draw_polygon(aTurtle, size=50, n=3): | |
''' 绘制正多边形 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# encoding: utf-8 | |
''' | |
本代码为使用calibre获取 乌云知识库<http://drops.wooyun.org/> 文章用的recipe, | |
可用来参考获取其他网站或博客电子书。 | |
使用方法参见: | |
http://blog.csdn.net/yelyyely/article/details/43741739 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"========================================================================= | |
" DesCRiption: 极简版vim配置 | |
" | |
" 替换本地vim配置文件命令: | |
" $ curl -O https://gist.githubusercontent.com/yely/f3c36c56c8db1e594633/raw/6db1aef4691c735182aef6ab0f5e9a9fd75377e1/simplest.vimrc && mv simplest.vimrc ~/.vimrc --backup=t | |
" or | |
" $ wget --no-check-certificate https://gist.githubusercontent.com/yely/f3c36c56c8db1e594633/raw/6db1aef4691c735182aef6ab0f5e9a9fd75377e1/simplest.vimrc && mv simplest.vimrc ~/.vimrc --backup=t | |
"========================================================================= | |
set nu " 设置行号 | |
syn on " 语法高亮 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# centos tmux install script. To install tmux version 2.0 instead of 1.6 installed by yum install command. | |
sudo yum install gcc make automake pkgconfig wget git-core ncurses-devel -y | |
mkdir ~/src | |
cd ~/src | |
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz | |
tar -zxvf libevent-2.0.21-stable.tar.gz | |
cd libevent-2.0.21-stable | |
./configure | |
make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from gevent import server | |
from gevent import monkey | |
monkey.patch_os() | |
from multiprocessing import Process, current_process, cpu_count | |
def eat_cpu(): | |
for i in xrange(100000): | |
pass |
OlderNewer