Skip to content

Instantly share code, notes, and snippets.

@LegendZhu
LegendZhu / gist:5735015
Last active December 18, 2015 05:48
通过PREVIEW_TOTLE、ROW_NUMBER参数控制页面的显示【总数表示标签不足时共显示多少格子】 元素少于配置时的总数空格补位和超过时的补位
<?php
define('PREVIEW_TOTLE', 15);//总数
define('ROW_NUMBER', 3);//每行的个数,应可被TOTLE整除
$total = PREVIEW_TOTLE;
$row = ROW_NUMBER;
$count = count($val['tag_ids']);
$last = $total - $count;
$j = 0;
@LegendZhu
LegendZhu / gist:6540457
Created September 12, 2013 16:35
一个基本的curl请求
<?php
protected $timeout = 10;
protected $connect_timeout = 2;
private $return_transfer = TRUE;
private $post = TRUE;
@LegendZhu
LegendZhu / lisp.rb
Created October 11, 2013 07:45 — forked from dahlia/lisp.rb
# 30 minutes Lisp in Ruby
# Hong Minhee <http://dahlia.kr/>
#
# This Lisp implementation does not provide a s-expression reader.
# Instead, it uses Ruby syntax like following code:
#
# [:def, :factorial,
# [:lambda, [:n],
# [:if, [:"=", :n, 1],
# 1,
@LegendZhu
LegendZhu / README.md
Created October 13, 2013 05:40 — forked from nikcub/README.md
<?php
// http://twitto.org/
require __DIR__.'/c.php';
if (!is_callable($c = @$_GET['c'] ?: function() { echo 'Woah!'; }))
throw new Exception('Error');
$c();
?>
<?php
// c.php
@LegendZhu
LegendZhu / latency.txt
Last active August 29, 2015 14:19 — forked from jboner/latency.txt
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
<?xml version="1.0" encoding="UTF-8" ?>
<opml version="1.0">
<head>
<title>寸志 subscriptions in Digg Reader</title>
</head>
<body>
<outline text="Framer Blog" title="Framer Blog" type="rss" xmlUrl="http://framerjs.tumblr.com/rss" htmlUrl="http://framerjs.tumblr.com/" />
<outline text="粉丝日志" title="粉丝日志" type="rss" xmlUrl="http://blog.fens.me/feed/" htmlUrl="http://blog.fens.me" />
<outline text="AngularJS" title="AngularJS" type="rss" xmlUrl="http://blog.angularjs.org/feeds/posts/default" htmlUrl="http://blog.angularjs.org/" />
<outline text="blog.izs.me" title="blog.izs.me" type="rss" xmlUrl="http://blog.izs.me/rss" htmlUrl="http://blog.izs.me/" />
@LegendZhu
LegendZhu / php-html-css-js-minifier.php
Created August 10, 2016 10:21 — forked from taufik-nurrohman/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* ----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/engine/plug/converter.php`
* ----------------------------------------------------------------------------------------
*/
@LegendZhu
LegendZhu / latency.md
Created December 18, 2017 15:43 — forked from marianposaceanu/latency.md
Latency numbers every programmer should know

CPU

  • L1 cache reference 0.5 ns
  • Branch mispredict 5 ns (on a bad CPU architecture you're pretty much screwed)
  • L2 cache reference 7 ns
  • Mutex lock/unlock 25 ns
  • Main memory reference 100 ns
  • Compress 1K bytes with Zippy 3,000 ns
  • Send 2K bytes over 1 Gbps network 20,000 ns
  • Read 1 MB sequentially from memory 250,000 ns
@LegendZhu
LegendZhu / latency.txt
Created December 18, 2017 15:44 — forked from jhclark/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 1 MB sequentially from memory 250,000 ns 0.25 ms
Round trip within same datacenter 500,000 ns 0.5 ms
Read 1 MB sequentially from SSD 1,000,000 ns 1 ms 4X memory