... or Why Pipelining Is Not That Easy
Golang Concurrency Patterns for brave and smart.
By @kachayev
<?php | |
/** | |
* ๅพฎไฟกPHP-SDK | |
* ๆๅกๅจ็ซฏๅฟ ้กป่ฆๆ CURL ๆฏๆ | |
* 2015ๅนด7ๆไฟฎๆญฃ็ๆฌ | |
* @author ใๅฐ้ๅๅ <[email protected]> | |
* https://coding.net/u/cjango/p/wechat_sdk/git | |
* 7ๆ10ๆฅ๏ผๅฎๅ็บขๅ ๅ่ฝ๏ผ | |
*/ | |
namespace Tools; |
... or Why Pipelining Is Not That Easy
Golang Concurrency Patterns for brave and smart.
By @kachayev
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# Copyright 2014 Cilyan Olowen <[email protected]> | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are | |
# met: | |
# | |
# * Redistributions of source code must retain the above copyright |
People
![]() :bowtie: |
๐ :smile: |
๐ :laughing: |
---|---|---|
๐ :blush: |
๐ :smiley: |
:relaxed: |
๐ :smirk: |
๐ :heart_eyes: |
๐ :kissing_heart: |
๐ :kissing_closed_eyes: |
๐ณ :flushed: |
๐ :relieved: |
๐ :satisfied: |
๐ :grin: |
๐ :wink: |
๐ :stuck_out_tongue_winking_eye: |
๐ :stuck_out_tongue_closed_eyes: |
๐ :grinning: |
๐ :kissing: |
๐ :kissing_smiling_eyes: |
๐ :stuck_out_tongue: |
WARNING: If you're reading this in 2021 or later, you're likely better served by reading:
(This gist was created in 2013 and targeted the legacy GOPATH mode.)
$ ssh -A vm
$ git config --global url."[email protected]:".insteadOf "https://github.com/"
Use $this to refer to the current object. Use self to refer to the current class. In other words, use $this->member for non-static members, use self::$member for static members.
Source: When to use self vs this -stackoverflow
This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)
The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array
it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array
part of it away. So how does that work?
The key here is that objects usually have a predefined set of keys, whereas arrays don't:
#!/usr/bin/env python | |
__author__ = 'Kevin Warrick' | |
__email__ = '[email protected]' | |
import cPickle | |
from functools import wraps | |
def redis_lru(capacity=5000, slice=slice(None)): | |
""" | |
Simple Redis-based LRU cache decorator *. |
<?php | |
class TailRecursion | |
{ | |
public $func; | |
public $acc; | |
public $recursing; | |
public function tail() | |
{ | |
return call_user_func_array($this->func, func_get_args()); |
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 ยตs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 ยตs
SSD random read ........................ 150,000 ns = 150 ยตs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 ยตs