Skip to content

Instantly share code, notes, and snippets.

View gautamk's full-sized avatar

Gautam gautamk

  • Block | Meta | Appdynamics | Cisco | Amazon | University of Washington
  • Seattle
View GitHub Profile
@gautamk
gautamk / CalendarGenerator.java
Created November 17, 2011 11:47
A problematic Calendar Generator
package ab2pdox;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* For generating a string containing a calender.
* Also contains useful enums to manage
*/
public class jcal {
@gautamk
gautamk / watermark.java
Created November 17, 2011 12:58
JavaWatermarkingScript
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.ArrayList;
public class wartermarker {
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once BASEPATH .'libraries/Zend/Acl.php';
class Acl extends Zend_Acl {
function __construct() {
$CI = &get_instance();
$this->acl = new Zend_Acl();
$CI->db->order_by('ParentId', 'ASC'); //Get the roles
$query = $CI->db->get('user_roles');
CREATE TABLE `user_resources` (
`id` INT NOT NULL AUTO_INCREMENT
, `name` VARCHAR(255)
, `description` VARCHAR(255)
, `parentId` INT DEFAULT NULL
, PRIMARY KEY (`id`)
);
CREATE TABLE `user_roles` (
`id` INT NOT NULL AUTO_INCREMENT
INSERT INTO `user_resources` (`id`, `name`, `description`, `parentId`) VALUES
(1, 'test', 'Acl Test Controller', NULLL)
INSERT INTO `user_roles` (`id`, `name`, `description`, `parentId`) VALUES
(1, 'test', 'Acl Test Role', NULLL)
INSERT INTO `user_permissions` (`id` ,`role` ,`resource` ,`read` ,`write` ,`modify` ,`delete` ,`publish`)
VALUES (NULL , '1', '1', '1', '1', '0', '0', '0');
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Test extends Controller {
function Test() {
parent::Controller()
$this->load->library('Acl');
define('ROLE', '1');
define('RESOURCE', '1');
}
function index() {
if (!$this->acl->can_read(ROLE, RESOURCE)) {
<?php
require_once 'Zend.php';
require_once 'Zend/Uri/Exception.php';
require_once 'Zend/Uri/Http.php';
require_once 'Zend/Uri/Mailto.php';
abstract class Zend_Uri
{
/**
@gautamk
gautamk / auth.php
Created February 4, 2012 15:10
CodeIgniter Authentication Library , application/libraries/auth.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Auth {
/**
* @author K.Gautam
* @version 0.1
* @todo ability to add configuration.
*/
protected $CI=NULL;
@gautamk
gautamk / single_line_php.sh
Created February 8, 2012 02:07
Testing single line php code
# What if you wanted to test a single line of code in php ?
# Simple
echo "<?php phpinfo();" | /path/to/php
# Since I am using XAMPP
# The following works
echo "<?php phpinfo();" | /opt/lampp/bin/php
@gautamk
gautamk / jqslide.html
Created February 18, 2012 15:51
A Simple jqeury based slideshow
<html>
<head>
<title>jQSlide</title>
</head>
<body>
<img src="" id="slide_show_pic" alt="">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">