Skip to content

Instantly share code, notes, and snippets.

View ruliarmando's full-sized avatar
🎮
Playing

Rully Ramanda ruliarmando

🎮
Playing
View GitHub Profile
@ruliarmando
ruliarmando / RulesMerger.php
Created February 22, 2014 06:31
RulesMerger (for Yii framework)
<?php
class RulesMerger
{
public static function merge()
{
$urlManager = Yii::app()->getUrlManager();
$path = Yii::getPathOfAlias('application.modules');
foreach(Yii::app()->getModules() as $k => $v)
{
@ruliarmando
ruliarmando / LoginForm.php
Last active August 29, 2015 13:56
Modified LoginForm
<?php
/**
* LoginForm class.
* LoginForm is the data structure for keeping
* user login form data. It is used by the 'login' action of 'SiteController'.
*/
class LoginForm extends CFormModel
{
public $username;
@ruliarmando
ruliarmando / UserIdentity.php
Last active August 29, 2015 13:56
Modified UserIdentity
<?php
/**
* UserIdentity represents the data needed to identity a user.
* It contains the authentication method that checks if the provided
* data can identity the user.
*/
class UserIdentity extends CUserIdentity
{
const ERROR_LIMIT_REACHED = 666;
@ruliarmando
ruliarmando / read_file.py
Created February 14, 2014 06:58
reading file into list
import sys
with open(sys.argv[1]) as the_file:
websites = [line.rstrip('\n') for line in the_file]
print websites
@ruliarmando
ruliarmando / index.php
Last active August 29, 2015 13:56
config class usage
<?php
require 'Config.php';
Config::load('config/main.php');
Config::set('timezone', 'Asia/Jakarta');
echo Config::get('base_url');
echo '<br />';
@ruliarmando
ruliarmando / main.php
Created February 6, 2014 08:33
simple configuration file
<?php
return array(
'base_url' => 'http://localhost/myapp/',
);
@ruliarmando
ruliarmando / Config.php
Created February 6, 2014 08:33
simple Config class
<?php
class Config {
private static $items = array();
public static function load($config_file){
self::$items = require $config_file;
}
@ruliarmando
ruliarmando / while-input.py
Created February 5, 2014 06:38
input while
while True:
nama = raw_input('Nama: ')
if not nama: continue
alamat = raw_input('Alamat: ')
if not alamat: continue
hobi = raw_input('Hobi: ')
if not hobi: continue
break;
print '\n\n'
import datetime
month_placeholder = {
'Jan' : 1,
'Feb' : 2,
'Mar' : 3,
'Apr' : 4,
'Mei' : 5,
'Jun' : 6,
'Jul' : 7,
@ruliarmando
ruliarmando / EWebUser.php
Created November 30, 2013 04:30
WebUser component (Yii Framework)
<?php class EWebUser extends CWebUser{
// ini buat pengecekan level akses tiap user
function getLevel(){
$level = Yii::app()->user->getState('level');
return $level;
}
function isAdmin(){ // apakah user adalah admin?
return Yii::app()->user->getState('level') == 1;