Skip to content

Instantly share code, notes, and snippets.

View fer-ri's full-sized avatar

Ferri Sutanto fer-ri

  • Purwokerto, Indonesia
View GitHub Profile

Requirments

  • bootstrap with typeahead
  • jquery

Explanation

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

@fer-ri
fer-ri / jQuery Simple Preload Images.js
Last active December 14, 2015 15:29
jQuery Simple Preload Images
function preload(arrayOfImages) {
$(arrayOfImages).each(function(){
$('<img />').attr('src',this).appendTo('body').hide();
});
}
// Usage:
preload([
'img/imageName.jpg',

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, www.foo.com 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.
<?php
// Resizer and Image Manipulation
// Based on: http://forums.laravel.com/viewtopic.php?id=2648
public function post_edit_logo($id)
{
$rules = array(
'image' => 'image',
);
public static function read_search($terms, $limit = 20)
{
$contact_results = Contact::where_account_user_id(Auth::user()->account_user_id)
->where_deleted(0)
->where_marketing(0)
->where_mass_merge(0)
->raw_where("match (`first`, `last`) against (?)", array($terms))
->take($limit)
->get();
// -----------
// 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() {
<?php
class Post
{
protected $table = 'posts';
/**
* You can define your own custom boot method.
*
* @return void
**/
@fer-ri
fer-ri / custom.js
Created August 28, 2013 10:47 — forked from drewjoh/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) {
e.preventDefault();
var url = $(this).attr('href');
if (url.indexOf('#') == 0) {
$(url).modal('open');
} else {
@fer-ri
fer-ri / BaseModel.php
Created October 10, 2013 14:33
BaseModel to extend Laravel Model and add some validation http://forums.laravel.io/viewtopic.php?pid=45695#p45695
<?php
// models/BaseModel.php
class BaseModel extends Eloquent
{
/**
* Errors returned by the validator.
*
<?php
/**
* @param string $domain Pass $_SERVER['SERVER_NAME'] here
* @param bool $debug
*
* @debug bool $debug
* @return string
*/
function get_domain($domain, $debug = false)
{