Skip to content

Instantly share code, notes, and snippets.

@cheeaun
cheeaun / color.php
Created October 2, 2009 08:30
Color class for Kohana
<?php defined('SYSPATH') or die('No direct script access.');
class Color {
public static function hex_to_rgb($hex){
$pattern = '/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/';
preg_match($pattern, $hex, $matches);
$matches = array_slice($matches, 1);
if (!function_exists('map')){
function map($value){
@mislav
mislav / pagination.md
Created October 12, 2010 17:20
"Pagination 101" by Faruk Ateş

Pagination 101

Article by Faruk Ateş, [originally on KuraFire.net][original] which is currently down

One of the most commonly overlooked and under-refined elements of a website is its pagination controls. In many cases, these are treated as an afterthought. I rarely come across a website that has decent pagination, and it always makes me wonder why so few manage to get it right. After all, I'd say that pagination is pretty easy to get right. Alas, that doesn't seem the case, so after encouragement from Chris Messina on Flickr I decided to write my Pagination 101, hopefully it'll give you some clues as to what makes good pagination.

Before going into analyzing good and bad pagination, I want to explain just what I consider to be pagination: Pagination is any kind of control system that lets the user browse through pages of search results, archives, or any other kind of continued content. Search results are the o

@valda
valda / danbooru_downloader.rb
Created November 2, 2010 01:54
Danbooru 一括ダウンローダー
#!/usr/bin/ruby
require 'rubygems'
require 'active_support'
require 'mechanize'
require 'optparse'
require 'fileutils'
Version = "1.0.0"
options = { :tag => nil, :dir => 'downloads' }
@bdotdub
bdotdub / redis.markdown
Created November 24, 2010 22:18
Running redis using upstart on Ubuntu

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@lxneng
lxneng / gist:741932
Created December 15, 2010 13:21
install PostgreSQL 9 in Mac OSX via Homebrew
install PostgreSQL 9 in Mac OSX via Homebrew
Mac OS X Snow Leopard
System Version: Mac OS X 10.6.5
Kernel Version: Darwin 10.5.0
Install notes for PostgreSQL 9.0.1 install using Homebrew:
sh-3.2# brew install postgresql
@momania
momania / gist:858476
Created March 7, 2011 13:05
Akka AMQP Loadbalance
import akka.amqp.AMQP._
import akka.amqp._
import akka.actor._
import java.util.concurrent.{TimeUnit, CountDownLatch}
import util.Random
object LoadBalancingDemo {
def main(args: Array[String]) {
@cheeaun
cheeaun / app.yaml
Created April 21, 2011 00:54
Simple static site hosting for Google App Engine WITHOUT any Python code at all. Just include this file, BOOM.
application: YOURAPPNAME
version: 1
runtime: python
api_version: 1
handlers:
- url: /
static_files: index.html
upload: index.html
- url: /(.*)
@erichurst
erichurst / database.yml.example mysql2
Created May 9, 2011 02:58
Rails 3 database.yml examples
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@kemo
kemo / search.php
Created May 26, 2011 13:35
Kohana Search controller example
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Search extends Controller {
/**
* @var Database_Result
*/
protected $_results;
/**