Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

何晨 hechen0

🎯
Focusing
View GitHub Profile
@hechen0
hechen0 / poll.c
Created Mar 21, 2020
poll example
View poll.c
#include <stdio.h>
#include <unistd.h>
#include <poll.h>
#define TIMEOUT 5 /* poll timeout, in seconds */
int main (void) {
struct pollfd fds[2];
int ret;
/* watch stdin for input */
fds[0].fd = STDIN_FILENO;
fds[0].events = POLLIN;
@hechen0
hechen0 / select.c
Created Mar 21, 2020
select_example
View select.c
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#define TIMEOUT 5 /* select timeout in seconds */
#define BUF_LEN 1024 /* read buffer in bytes */
int main (void) {
struct timeval tv;
View gistachio-is-cool.txt
tttt tttt iiii
ttt:::t ttt:::t i::::i
t:::::t t:::::t iiii
t:::::t t:::::t
ttttttt:::::ttttttt eeeeeeeeeeee ssssssssss ttttttt:::::ttttttt iiiiiiinnnn nnnnnnnn ggggggggg ggggg
t:::::::::::::::::t ee::::::::::::ee ss::::::::::s t:::::::::::::::::t i:::::in:::nn::::::::nn g:::::::::ggg::::g
t:::::::::::::::::t e::::::eeeee:::::eess:::::::::::::s t:::::::::::::::::t i::::in::::::::::::::nn g:::::::::::::::::g
tttttt:::::::tttttt e::::::e e:::::es::::::ssss:::::stttttt:::::::tttttt i::::inn:::::::::::::::ng::::::ggggg::::::gg
@hechen0
hechen0 / yuntiserver.rb
Created Jan 28, 2016
pick the fastest server from cloudtizi.com
View yuntiserver.rb
PING_COUNT = 3
LATENCY_STATUS = /^round-trip min\/avg\/max\/stddev = [\d.]+\/([\d.]+)\/[\d.]+\/[\d.]+ ms/
def ping(host)
p "pinging... #{host}"
cmd = "ping -c #{PING_COUNT} #{host}"
`#{cmd}`
end
View What is it that we love about Sherlock Holmes?
First, I am so fascinated by puzzle-solving just as Holmes does. As a detective, Holmes is the Master puzzle-solver, and he makes it a science and then reveals so well how he does it.
Second, Holmes shows us life as we wish it could be. Would that all our own problems could be solved by this great intellect, or that today's crimes could be approached with such scientific diligence and care. His work helps us to maintain a sense of fairness always. In a world in which evil often trumphs over good and evildoers get away with more than murder, this ideal is a cherished one indeed.
View Reasons Why Harry Potter is Awesome
Harry Potter is the last book you should miss. For those who refuse to give Harry Potter a chance, here is my ammunition to turn them on to the Wizarding World.
First, let me remind you, J.K, Rowling is a BILLIONAIRE, richer than the queen of UK, just because she wrote seven children's novels. It shows how popular and great the book is, Plain and simple, the books tell a great story. It's epic, especially for a children's series, but it's not terribly long.
Second, it is so educational. Children's books are supposed to be tools for teaching and yet too many of them beat the kids over their heads with their message. Most kids widh they had magic to take care of their problems. Harry Potter teaches kids that life is rough(and won't be all sugar plums and fairy tales, even if you do have magic spells to clean your root)Let's be honest, how many children's books and movies will start off with the main characters parents being murdered in the first chapter of the first book?Life is like that, and that's the reas
View Mona Lisa's Secret Revealed Sample Answer
Mona Lisa is a unique painting that i enjoy most.
Mona Lisa is facing us directly. As we watch her bloom into a smile, we cannot help but feel that it is our presence that is causing her to smile, and we cannot help feeling a positive connection with the woman.
But we are suddenly aware of another, negative side of our connection to her. Is it possible that, rather than breaking out into a smile, her face is undergoing the opposite motion, losing the traces of a full smile that she had a moment earlier?
The picture offers no answer. An ordinary painting cannot evoke in us such a complexity and dynamicity of emotions. No wonder this painting is considered so great ...
@hechen0
hechen0 / loopCrawler.js
Created Dec 1, 2013
crawl two url using for loop , poor
View loopCrawler.js
function download(url, callback){
http.get(url, function(res){
var data="";
res.on('data', function(chunk){
data += chunk;
});
res.on('end', function(){
callback(data);
@hechen0
hechen0 / webcrawler.js
Created Dec 1, 2013
first to create web crawler with node js
View webcrawler.js
var http = require('http'),
cheerio = require('cheerio');
startUrl = 'http://www.renren.com';
var urls = [startUrl];
var tags = ["div","h1","h2","h3","h4","h5","img","a"]
// Utility function that downloads a URL and invokes callback