Skip to content

Instantly share code, notes, and snippets.

<?php
// Load eloquent
require 'vendor/autoload.php';
// Setting eloquent
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
<?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
{
private $id;
<?php
class WebUser extends CWebUser {
public function checkAccess($operation, $params = array()) {
if (empty($this->id)) {
return false;
}
$role = $this->getState("roles");
if ($role === 'admin') {
return true;
@jokosusilo
jokosusilo / ScrollDown.js
Created August 11, 2014 04:53
Scroll Down
$(document).ready(function() {
var track_load = 0; //total loaded record group(s)
var loading = false; //to prevents multipal ajax loads
var total_groups = 10; //total record group(s)
$('#results').load("autoload_process.php", {'group_no':track_load}, function() {track_load++;}); //load first group
$(window).scroll(function() { //detect page scroll
if($(window).scrollTop() + $(window).height() == $(document).height()) //user scrolled to bottom of the page?
{
if(track_load <= total_groups && loading==false) //there's more data to load
{
<!-- view -->
<input type="file" class="form-control" id="image" name="image" required>
<?php
// Controller
// fungsi insert
public function store(){
$config['upload_path'] = './assets/produk/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '20000';
@jokosusilo
jokosusilo / Image Upload Preview
Created April 14, 2015 06:01
Preview image setelah memilih file gambar
<!DOCTYPE html>
<!-- Based on HTML5 Bones | http://html5bones.com -->
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page Title</title>
<meta name="description" content="">
<!-- Mobile-friendly viewport -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Style sheet link -->
@jokosusilo
jokosusilo / webdeveloper
Last active August 29, 2015 14:20
Requirement web developer
Auth
-simple (Access Control List)
-advanced (Role Based Access Control)
-hand made Authentication
Caching
-DB Caching
-File Caching
-Mem Caching
-Image Caching
@jokosusilo
jokosusilo / optimize website
Created April 28, 2015 04:28
Beberapa hal yang bisa dilakukan untuk mempercepat loading dan optimaliasi website
minification of files
zipping css / js files
pulling all css files into one
pulling all js files into one
creating image sprites that combined many images into one big sprite
avoid using IE specific css expressions
using a cdn to serve files
loading js at bottom of page
serving files from a different domain
serving files asynchronously after page has loaded
@jokosusilo
jokosusilo / optimize website
Created April 28, 2015 04:28
Beberapa hal yang bisa dilakukan untuk mempercepat loading dan optimaliasi website
minification of files
zipping css / js files
pulling all css files into one
pulling all js files into one
creating image sprites that combined many images into one big sprite
avoid using IE specific css expressions
using a cdn to serve files
loading js at bottom of page
serving files from a different domain
serving files asynchronously after page has loaded
@jokosusilo
jokosusilo / Kabupaten_Model.php
Created June 4, 2015 01:35
Pagination di Codeigniter 3
<?php
class Kabupaten_Model extends CI_Model{
public function __construct(){
parent:: __construct();
}
// Pagination biasa
public function countAll(){
return $this->db->count_all('kabupaten');