Skip to content

Instantly share code, notes, and snippets.

View satlavida's full-sized avatar

Satyajeet Nigade satlavida

View GitHub Profile
@satlavida
satlavida / flash_messages.php
Created May 21, 2011 13:58 — forked from BaylorRae/flash_messages.php
Flash Messages for PHP
<?php
class FlashMessages {
private $messages = array();
private $now = false;
private function __construct() {
// Save all messages
$this->messages = $_SESSION['flash_messages'];
@satlavida
satlavida / pagger.coffee
Created August 14, 2011 06:32
Pagination using collections: Backbone.js
class Pager
constructor: (collection, attributes) ->
@collection = collection
@currentPage = attributes.current_page
@totalPages = attributes.total_pages
@perPage = attributes.per_page
@totalEntries = attributes.total_entries
@pages = @visiblePageNumbers().map (page) =>
page: page
path: @buildPath page
@satlavida
satlavida / paginated_collection.js
Created August 15, 2011 05:44 — forked from zerowidth/paginated_collection.js
first whack at pagination with backbone.js
// includes bindings for fetching/fetched
PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
this.page = 1;
},
fetch: function(options) {
options || (options = {});
this.trigger("fetching");
@satlavida
satlavida / gist:1145903
Created August 15, 2011 08:31
Mac ipconfig/flushdns
dscacheutil -flushcache
@satlavida
satlavida / h.php
Created September 1, 2011 12:59 — forked from alganet/h.php
HTML generator prototype
<?php
print
h::html(
h::head(
h::title('Hi!')
),
h::body(
h::h1('Hello')->id('oi'),
h::ul(
@satlavida
satlavida / datastore.php
Created September 2, 2011 16:57
Data Store in PHP
<?php
class DataStore
{
public function __call($methodName, $args) {
if (preg_match('~^(set|get)([A-Z])(.*)$~', $methodName, $matches)) {
$property = strtolower($matches[2]) . $matches[3];
if (!property_exists($this, $property)) {
throw new Exception("Error Processing Request",1);
}
<?php
class DB
{
public static function __callStatic($name,$args)
{
$q= "";
$query = explode("_",$name);
if($query[0] == "get")
{
"puts :hi"
@satlavida
satlavida / gist:1261864
Created October 4, 2011 15:00 — forked from justingraves/gist:180177
A little rounded black tooltip you can easily point at stuff
/*
* CPTooltip.j
* Makes a little black rounded-rect gradient tooltip with some text (can have multiple lines with \n) which points at something.
* Usage example:
* tooltip = [[CPTooltip alloc] initWithText:@"Hello There" atPoint:CPPointMake(100,100)];
* [self addSubview:tooltip];
*
* The above will make a tooltip that says "Hello There" which is pointing at this view's 100x100 point.
* If the tooltip is too close to its superview's edges, it will adjust itself to maintain readability.
*
@satlavida
satlavida / CPLightbox.j
Created October 4, 2011 15:01 — forked from nickjs/CPLightbox.j
CPLightbox Modals and Sheets
/*
* CPLightbox.j
* AppKit
*
* Created by Nicholas Small.
* Copyright 2009, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either