Skip to content

Instantly share code, notes, and snippets.

View chonthu's full-sized avatar

Nithin Meppurathu chonthu

View GitHub Profile
def index = Action {
Ok(Scalate("index.ssp").render('title -> "Hello World"));
}
package controllers
import play.api._
import http.{Writeable, ContentTypeOf, ContentTypes}
import mvc.Codec
import play.api.Play.current
import org.fusesource.scalate.layout.DefaultLayoutStrategy
object Scalate {
# Default Scalate template format (mustache, scaml, jade, ssp)
scalate.format=ssp // you can choose any supported template
val appDependencies = Seq(
// Add your project dependencies here,
"org.fusesource.scalate" % "scalate-core_2.10" % "1.6.1"
)
@chonthu
chonthu / gist:2166526
Created March 23, 2012 03:40
nginx initd
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@chonthu
chonthu / gist:1924447
Created February 27, 2012 15:09
nginx sample config
server {
server_name .sandbox.com;
root /var/www;
# set expiration of assets to MAX for caching
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
}
@chonthu
chonthu / gist:1893494
Created February 23, 2012 16:15
on_duplicate_update 7
$update = array_keys($data);
unset($update['created_at']);
$this->db->set($data)->on_duplicate_update('product',$update);
@chonthu
chonthu / gist:1893490
Created February 23, 2012 16:15
on_duplicate_update 6
class MY_Loader extends CI_Loader {
/**
* Database Loader
*
* @access public
* @param string the DB credentials
* @param bool whether to return the DB object
* @param bool whether to enable active record (this allows us to override the config setting)
* @return object
@chonthu
chonthu / gist:1893489
Created February 23, 2012 16:14
on_duplicate_update 5
<?
class MY_DB_mysqli_driver extends CI_DB_mysqli_driver
{
final public function __construct($params)
{
parent::__construct($params);
}
function _insert_on_duplicate_update($table, $update, $values)
@chonthu
chonthu / gist:1893486
Created February 23, 2012 16:14
on_duplicate_update 4
<?
class MY_DB_active_record extends CI_DB_active_record
{
function on_duplicate_update($table = '',$fields = NULL,$set = NULL)
{
if ( ! is_null($set))
{
$this->set($set);
}