Skip to content

Instantly share code, notes, and snippets.


Ferri Sutanto ghprod

  • Purwokerto, Indonesia
View GitHub Profile


  • bootstrap with typeahead
  • jquery


This will use bootstrap with typeahead to create an autocomplete search.

ghprod / jQuery Simple Preload Images.js
Last active Dec 14, 2015
jQuery Simple Preload Images
View jQuery Simple Preload Images.js
function preload(arrayOfImages) {
$('<img />').attr('src',this).appendTo('body').hide();
// Usage:
View nginx + node

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

  1. nginx is used to serve static files (css, js, images, etc.)
  2. node serves all the "dynamic" stuff.

So for example, request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

  1. nginx listens on port 80.
View laravel-upload-resize.php
// Resizer and Image Manipulation
// Based on:
public function post_edit_logo($id)
$rules = array(
'image' => 'image',
View fulltextsearch.php
public static function read_search($terms, $limit = 20)
$contact_results = Contact::where_account_user_id(Auth::user()->account_user_id)
->raw_where("match (`first`, `last`) against (?)", array($terms))
View viewport.js
// -----------
// Debugger that shows view port size. Helps when making responsive designs.
// -----------
function showViewPortSize(display) {
if(display) {
var height = jQuery(window).height();
var width = jQuery(window).width();
jQuery('body').prepend('<div id="viewportsize" style="z-index:9999;position:fixed;top:40px;left:5px;color:#fff;background:#000;padding:10px">Height: '+height+'<br>Width: '+width+'</div>');
jQuery(window).resize(function() {
View eloquent.php
class Post
protected $table = 'posts';
* You can define your own custom boot method.
* @return void
View custom.js
$(document).ready(function() {
// Support for AJAX loaded modal window.
// Focuses on first input textbox after it loads the window.
$('[data-toggle="modal"]').click(function(e) {
var url = $(this).attr('href');
if (url.indexOf('#') == 0) {
} else {
ghprod / BaseModel.php
Created Oct 10, 2013
BaseModel to extend Laravel Model and add some validation
View BaseModel.php
// models/BaseModel.php
class BaseModel extends Eloquent
* Errors returned by the validator.
View get domain without subdomain.php
* @param string $domain Pass $_SERVER['SERVER_NAME'] here
* @param bool $debug
* @debug bool $debug
* @return string
function get_domain($domain, $debug = false)