Skip to content

Instantly share code, notes, and snippets.

View rishav's full-sized avatar

Rishav Rastogi rishav

View GitHub Profile
@rishav
rishav / gist:5803756
Created June 18, 2013 08:54
Simple Bash Profile
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
source ~/.bashrc
source ~/.scripts/.git-completion.bash
#for adding branch to the terminal
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
@rishav
rishav / gist:4284455
Created December 14, 2012 10:39
Example of SSH config, setting up hostname shortcuts
Host production
Hostname production.example.com
User ubuntu
IdentityFile ~/secretlocation/example.pem
Host staging
Hostname staging.example
User deploy
if(Yii::app()->user->isSuperuser)
$type=$_POST['Type'];</div>
else
 $type='User';
$authorizer = Yii::app()-&gt;getModule("rights")-&gt;getAuthorizer();
$authorizer-&gt;authManager-&gt;assign($type, $model-&gt;id);
$data_entry_users=Yii::app()->getAuthManager()->getAssignmentsByItemName('DataEntry');
$data_entry_users_id=array();
foreach($data_entry_users as $id=>$assignment)
$data_entry_users_id[]=$id;
$roles=Rights::getAssignedRoles(Yii::app()->user->Id);
foreach($roles as $role)
echo $role->name."<br />";
var_dump(Yii::app()->getModule("rights")->getAuthorizer()->getSuperusers());
if(Yii::app()->user->isSuperuser)
echo "I am one of the superuser of application, I have all access to app.";
'user'=>array(
//
//
'identityCookie' => array('domain' => '.domain.com'),
//
),
'session' => array(
'autoStart'=>true,
'cookieParams' => array('domain' => '.domain.com'),
...
@rishav
rishav / gist:1500517
Created December 20, 2011 06:18
Vim : Delete commands
dgg : will delete to the beginning of the file.
d$ : will delete from the current position to the end of the current line.
dG : will delete to the end of the file.
d0 : will delete to the beginning of the file
dw: will delete a word
>> ActiveSupport::SecureRandom.base64(10)
=> "Fa8ILYFgMA12LA=="
>> ActiveSupport::SecureRandom.hex(6)
=> "82c82a15110a"
>> ActiveSupport::SecureRandom.random_bytes(16)
=> "u[\205\326\2654\301;'\340\372\2539r\035\313"
>> ActiveSupport::SecureRandom.random_number(5)
=> 0