- Do you have an Github account ? If not create one.
- Install required tools
- Latest Git Client
- gpg tools
# Ubuntu
sudo apt-get install gpa seahorse
# MacOS with https://brew.sh/
#!/usr/bin/env ruby | |
# List all keys stored in memcache. | |
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place. | |
require 'net/telnet' | |
headings = %w(id expires bytes cache_key) | |
rows = [] |
<?php | |
/* | |
参考自: | |
http://darklaunch.com/2010/09/01/http-status-codes-in-php-http-header-response-code-function | |
http://snipplr.com/view/68099/ | |
*/ | |
function HTTPStatus($num) { | |
$http = array( |
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'aws-sdk' | |
#creates an interface object to AWS S3 | |
AWS.config( :access_key_id => '' , :secret_access_key => '' ) | |
#creates an interface to the S3 | |
s3interface = AWS::S3.new | |
<?php | |
/* | |
* Get all users registered after $start and before $end (dates in yyyy-mm-dd format) | |
* | |
* Based on my answer to this question: http://wordpress.stackexchange.com/questions/51485/how-can-i-query-all-users-who-registered-today/51492#51492 | |
* | |
* @param (string) $start - start date in yyyy-mm-dd format | |
* @param (string) $end - end date in yyyy-mm-dd format | |
*/ | |
// include the AMQPlib Classes || use an autoloader | |
// queue/exchange names | |
$queueRightNow = 'right.now.queue'; | |
$exchangeRightNow = 'right.now.exchange'; | |
$queueDelayed5sec = 'delayed.five.seconds.queue'; | |
$exchangeDelayed5sec = 'delayed.five.seconds.exchange'; | |
$delay = 5; // delay in seconds | |
openssl pkcs7 -print_certs -in old.p7b -out new.crt | |
# openssl pkcs7 -print_certs -in old.p7b -out new.cer |
<?php | |
function cidr_match($ip) { | |
foreach(file('https://www.cloudflare.com/ips-v4') as $cidr) { | |
list($subnet, $mask) = explode('/', $cidr); | |
if ((ip2long($ip) & ~((1 << (32 - $mask)) - 1) ) == ip2long($subnet)) { | |
return true; |
require 'socket' | |
# 1. Create | |
# AF_INET means IPv4 (xxx.xxx.xxx.xxx) | |
# SOCK_STREAM means communicating with a stream (TCP) | |
# | |
# Can be simplified to symbols :INET and :STREAM, respectively | |
server = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM) |
# Ubuntu
sudo apt-get install gpa seahorse
# MacOS with https://brew.sh/
Optimistic Locking assumes that a database transaction conflict is very rare to happen. It uses a version number of the record to track the changes. It raise an error when other user tries to update the record while it is lock.
usage
Just add a lock_version column to the table you want to place the lock and Rails will automatically check this column before updating the record.
Pessimistic locking assumes that database transaction conflict is very likely to happen. It locks the record until the transaction is done. If the record is currently lock and the other user make a transaction, that second transaction will wait until the lock in first transaction is release.
usage