Skip to content

Instantly share code, notes, and snippets.

# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@jaceju
jaceju / create_zf_project.sh
Created November 3, 2011 02:58
利用專案樣版在 Subversion 中建立一個 Zend Framework 專案
#!/bin/bash
# Program:
# 利用專案樣版在 Subversion 中建立一個 Zend Framework 專案
# History:
# 2011/11/03 Jace Ju First release
# Usage:
# Create template of project at first time:
# > cd /path/to/project_template
# > mkdir branches
# > mkdir tags
<?php
trait Singleton
{
protected static $_instance = null;
public static function getInstance()
{
if (static::$_instance === null
|| !(static::$_instance instanceof static)) {
@irazasyed
irazasyed / Install Composer using MAMP's PHP.md
Last active April 2, 2024 18:45
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management

Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management


Instructions to Change PHP Installation


First, Lets find out what version of PHP we're running (To find out if it's the default version).

To do that, Within the terminal, Fire this command:

which php

@krakjoe
krakjoe / pthreads.md
Last active August 30, 2023 18:30
pthreads.md

Multi-Threading in PHP with pthreads

A Brief Introduction to Multi-Threading in PHP

  • Foreword
  • Execution
  • Sharing
  • Synchronization
  • Pitfalls

Falsehoods programmers believe about prices

  1. You can store a price in a floating point variable.
  2. All currencies are subdivided in 1/100th units (like US dollar/cents, euro/eurocents etc.).
  3. All currencies are subdivided in decimal units (like dinar/fils)
  4. All currencies currently in circulation are subdivided in decimal units. (to exclude shillings, pennies) (counter-example: MGA)
  5. All currencies are subdivided. (counter-examples: KRW, COP, JPY... Or subdivisions can be deprecated.)
  6. Prices can't have more precision than the smaller sub-unit of the currency. (e.g. gas prices)
  7. For any currency you can have a price of 1. (ZWL)
  8. Every country has its own currency. (EUR is the best example, but also Franc CFA, etc.)
@luxixing
luxixing / phpstorm
Created October 24, 2013 11:04
PHPStorm 使用技巧
快捷键:
ctrl+tab: switcher,在已打开文件之间或者工具窗口间切换
alt+alt: 连续两次快速按下alt键不放,显示tool windows(project,database ...)
ctrl+k: 快速调用 commit changes 对话框
alt+F3: 显示搜索窗格,对当前文件进行搜索,然后配合ctrl+alt+r,可以进行替换操作
ctrl+shift+f: find in path 在指定文件夹或者整个project内搜索,ctrl+shift+r进行替换操作
ctrl+shift+alt+t: 快速rename,里面有好几个选项,慢慢理解吧
shift+F6: rename,自动重命名该变量所有被调用的地方
ctrl+shift+n: 快速导航到指定文件,弹出一个dialog,输入文件名即可
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active February 12, 2024 17:18
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@pjdietz
pjdietz / cloudSettings
Last active June 18, 2020 22:29
Testing Protected Method of Abstract Class with PHPUnit
{"lastUpload":"2020-06-18T22:29:09.889Z","extensionVersion":"v3.4.3"}
@dong920740928
dong920740928 / gearman_java中的使用.md
Last active August 3, 2017 11:12
gearman_java中的使用

2 用java编写gearman的client端及端程序

2.1 加入包依赖

这里给出maven中应添加的依赖,直接copy进pom.xml即可 org.gearman.jgs java-gearman-service [0.7.0-SNAPSHOT,)