Skip to content

Instantly share code, notes, and snippets.

View sandeepone's full-sized avatar
💭
I may be slow to respond.

Sandeep Sangamreddi sandeepone

💭
I may be slow to respond.
View GitHub Profile
<?php
class Pagination {
public static function factory($total, $limit = 5, $page = 1, $adjacents = 2)
{
return new Pagination($total, $limit, $page, $adjacents);
}
public $total;
@nexeck
nexeck / gist:1257411
Created October 2, 2011 12:38 — forked from daGrevis/gist:1257357
Route for mini-CMS
<?php
Route::set('cms', function($uri) {
$is_empty = empty($uri);
$does_exists = class_exists('Controller_' . $uri);
if ($is_empty || $does_exists) {
$default_route = Route::get('default');
@mikeyk
mikeyk / gist:1329319
Created October 31, 2011 22:56
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@jambu
jambu / gmail-scrollbars.css
Created March 9, 2012 02:17 — forked from Cifro/gmail-scrollbars.css
New Gmail like scrollbars for webkit browsers
/* Gmail style scrollbar */
::-webkit-scrollbar {
width: 12px
}
::-webkit-scrollbar-thumb {
border-width: 1px 1px 1px 2px
}
::-webkit-scrollbar-track {
border-width: 0
}
@nictuku
nictuku / sshd.go
Created April 8, 2012 15:43
Go SSH server complete example
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"code.google.com/p/go.crypto/ssh"
"code.google.com/p/go.crypto/ssh/terminal"
@ebidel
ebidel / handle_file_upload.php
Created April 18, 2012 03:23
Uploading files using xhr.send(FormData) to PHP server
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
@kemo
kemo / Cached.php
Created April 27, 2012 21:36
Cache-powered ORM model extension (Kohana 3.3) - [!!] Not tested
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Extend this class if you want your model cached. Example usage:
*
* 1. Model
* class Model_User extends ORM_Cached {}
*
* 2. Usage
*
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@larrybolt
larrybolt / cf-ddns.sh
Last active April 29, 2024 13:34
Automatically update your CloudFlare DNS record to the IP, Dynamic DNS for Cloudflare
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
# Automatically update your CloudFlare DNS record to the IP, Dynamic DNS
# Can retrieve cloudflare Domain id and list zone's, because, lazy
# Place at:
# /usr/local/bin/cf-ddns.sh
@mschubert
mschubert / encfs-rsync.sh
Last active May 4, 2016 04:33
Script to (decrypt encfs and) selectively sync a remote sshfs directory
#!/bin/bash
# Script to (decrypt encfs and) selectively sync a remote sshfs directory
REMOTEDIR=server:/path/to/some/encfs
LOCALDIR=/path/to/local/directory
MOUNTFUNC=_ssh+encfs
# verbose
# set -vx