Skip to content

Instantly share code, notes, and snippets.

$ find /path/to -type d -exec chmod 775 {} \;
$ find /path/to -type f -exec chmod 664 {} \;
<?php
class Assert extends PHPUnit_Framework_Assert
{
/**
* Alias for PHPUnit's assertions methods
*
* The key is the alias name, which can be used as a method, and the value is the full name of the (PHPUnit) method
*
* @var array
*/
<?php
class Application_Model_Posts
{
public function getPosts()
{
$posts = new Application_Model_DbTable_Posts();
$select = $posts->select()->order('created_at DESC')
->order('id DESC');
return $posts->fetchAll($select);
@bladeofsteel
bladeofsteel / mongo_group.js
Created May 12, 2011 11:38
How to calculate sum in mongo collection
db.coll.group({ key: {}, initial: {csum: 0}, reduce: function(obj,prev){ prev.csum += obj.field;}});
@bladeofsteel
bladeofsteel / gist:1082265
Created July 14, 2011 10:55
Предварительное создание файлов баз данных для MongoDB
for i in {0..40}
do
echo $i
head -c 2146435072 /dev/zero > local.$i
done
@bladeofsteel
bladeofsteel / bcrypt.php
Created October 2, 2011 06:51 — forked from dzuelke/bcrypt.php
How to use bcrypt in PHP to safely store passwords (PHP 5.3+ only)
<?php
// secure hashing of passwords using bcrypt, needs PHP 5.3+
// see http://codahale.com/how-to-safely-store-a-password/
// salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt
// just an example; please use something more secure/random than sha1(microtime) :)
$salt = substr(str_replace('+', '.', base64_encode(sha1(microtime(true), true))), 0, 22);
// 2a is the bcrypt algorithm selector, see http://php.net/crypt
# git
alias gl='git pull'
alias glom='git pull origin master'
alias gp='git push'
alias gpom='git push origin master'
alias gd='git diff'
alias gc='git commit -m'
alias gca='git commit -a -m'
alias gco='git checkout'
alias gb='git branch'
@bladeofsteel
bladeofsteel / gist:1320364
Created October 27, 2011 18:19
my prompt for bash console
PS1='\n${debian_chroot:+($debian_chroot)}\[\e[1;35m\][\u@\h]\[\e[1;37m\]──\[\e[1;32m\][\w]\[\e[1;37m\]──\[\e[1;34m\]$(__git_ps1 "[ %s ]")\[\e[1;37m\]──\[\e[1;30m\](\t)\[\e[1;37m\]\n\[\e[1;35m\]>\[\e[m\] '
@bladeofsteel
bladeofsteel / h5bp-twitter-bootstrap
Created December 6, 2011 08:01 — forked from mklabs/bootstrap-plugins.txt
h5bp + twitter bootstrap integration
#!/bin/sh
echo "
Cool, let's start.
"
src=$PWD
@bladeofsteel
bladeofsteel / gist:1466280
Created December 12, 2011 09:49
иммитация кнопки клавиатуры
kbd {
background: none repeat scroll 0 0 #EEEEEE;
border-color: #CCCCCC #AAAAAA #888888 #BBBBBB;
border-style: solid;
border-width: 1px 3px 3px 1px;
color: #000000;
padding: 2px 4px;
white-space: nowrap;
font-family: Monaco,"DejaVu Sans Mono",Courier,monospace;
}