Skip to content

Instantly share code, notes, and snippets.

// cross-browser width and height functions
function f_clientWidth() {
return f_filterResults (
window.innerWidth ? window.innerWidth : 0,
document.documentElement ? document.documentElement.clientWidth : 0,
document.body ? document.body.clientWidth : 0
);
}
function f_clientHeight() {
return f_filterResults (
@aenigme
aenigme / .htaccess
Created August 6, 2010 16:02
Kohana htaccess file
RewriteEngine on
RewriteBase /
# Add www rule
# RewriteCond %{HTTP_HOST} ^example.com$ [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# Remove www rule
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
@Akkuma
Akkuma / jquery.innershiv.js
Created March 25, 2011 20:15
An integrated innershiv
// jQuery patch for HTML5 elements using innerShiv by https://github.com/andy-clusta
(function ($) {
var init = jQuery.fn.init; rootjQuery = jQuery(document);
// http://jdbartlett.github.com/innershiv | WTFPL License
var innerShiv = (function() {
var div, frag,
inaTable = /^<(tbody|tr|td|col|colgroup|thead|tfoot)/i,
remptyTag = /(<([\w:]+)[^>]*?)\/>/g,
rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
@klmr
klmr / range.hpp
Created September 2, 2012 15:06
Range-based for in C++
#ifndef UTIL_LANG_RANGE_HPP
#define UTIL_LANG_RANGE_HPP
#include <iterator>
namespace util { namespace lang {
namespace detail {
template <typename T>
@chrisguitarguy
chrisguitarguy / checker.go
Created September 8, 2012 22:52
A simple URL status checker in Go. Made to practice a bit with channels and goroutines.
package main
import (
"bufio"
"container/list"
"flag"
"fmt"
"net/http"
"io"
"os"
@juandopazo
juandopazo / result.js
Created October 6, 2012 17:33
YUI TypeScript definitions
module Y {
interface Anim extends Base {
}
interface App extends App_Base, App_Content, App_Transitions, PjaxContent {
(config?: any);
@klmr
klmr / string.hpp
Created October 12, 2012 17:21
Ultra-simple string class
#ifndef TEXT_STRING_HPP
#define TEXT_STRING_HPP
#include <algorithm>
#include <cstring>
#include <iterator>
#include <memory>
#include <iosfwd>
namespace text {
@klmr
klmr / gist:4250731
Created December 10, 2012 14:04
C++11 enum classes boilerplate
enum class dna_strand : char {
positive = '+',
negative = '-'
};
std::ostream& operator <<(std::ostream& out, dna_strand strand) {
return out << static_cast<char>(strand);
}
std::istream& operator >>(std::istream& in, dna_strand& strand) {
@dznz
dznz / gist:f9dcd594427aa31f6d8f
Created October 10, 2014 01:26
Set up a read-only user in Postgresql
CREATE ROLE readonly LOGIN PASSWORD 'some_pass';
-- Existing objects
GRANT CONNECT ON DATABASE the_db TO readonly;
GRANT USAGE ON SCHEMA public TO readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO readonly;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO readonly;
-- New objects
ALTER DEFAULT PRIVILEGES FOR owner_user IN SCHEMA public GRANT SELECT ON TABLES TO readonly;
ALTER DEFAULT PRIVILEGES FOR owner_user IN SCHEMA public GRANT SELECT ON SEQUENCES TO readonly;
@klmr
klmr / auto_cast.hpp
Last active December 16, 2015 09:28
template <typename Source>
struct auto_cast_helper {
Source const& value;
explicit auto_cast_helper(Source const& value) : value(value) { }
template <typename Target>
operator Target() const {
return static_cast<Target>(value);
}