Skip to content

Instantly share code, notes, and snippets.

@thinkphp
thinkphp / gist:1440007
Created December 6, 2011 21:06
Breadth-First Traversal of a Binary Tree.js
/**
* Breadth-First Traversal of a Binary Tree in JS
* by Adrian Statescu <[email protected]>
* MIT Style License
*/
function Node(info){
this.info = info
this.left = null;
@adhipg
adhipg / countries.sql
Created January 12, 2012 11:41
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@RaVbaker
RaVbaker / readme.md
Created March 30, 2012 20:12
[HOWTO] Rewrite all urls to one index.php in Apache

Redirect All Requests To Index.php Using .htaccess

In one of my pet projects, I redirect all requests to index.php, which then decides what to do with it:

Simple Example

This snippet in your .htaccess will ensure that all requests for files and folders that does not exists will be redirected to index.php:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

@tsyber1an
tsyber1an / data.json
Created April 10, 2012 09:07
simple force-directed graph using d3
{
"nodes": [
{
"name": "Myriel",
"group": 1
},
{
"name": "Napoleon",
"group": 1
},
@manigandanta
manigandanta / calendar-script.php
Created April 11, 2012 05:56
Calendar script
<?php
$home1="sunrise-sunset-day_".$sun_value."_";
//$bgcolor="#898989";
//$tablecolor = "#675645";
//$fontcolor = "#EE49DD";
//$tableborder = "458866";
//Edit the below three lines to change the colors (Look and Feel of the calander).
//The default values are shown in the above lines
$bgcolor="#4B9E03";
@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,
@mironal
mironal / content_type_json.php
Created June 16, 2012 01:10
header("Content-type: application/json; charset=utf-8"); php
<?php
header("Content-type: application/json; charset=utf-8");
/* something... */
?>
@fcingolani
fcingolani / index.html
Created August 9, 2012 02:16
How to render a full PDF using Mozilla's pdf.js
<html>
<body>
<!-- really dirty! this is just a test drive ;) -->
<script type="text/javascript" src="https://raw.github.com/mozilla/pdf.js/gh-pages/build/pdf.js"></script>
<script type="text/javascript">
function renderPDF(url, canvasContainer, options) {
var options = options || { scale: 1 };
@hakre
hakre / iconv-l.txt
Created December 2, 2012 12:35
Iconv List of Encodings
ANSI_X3.4-1968 ANSI_X3.4-1986 ASCII CP367 IBM367 ISO-IR-6 ISO646-US ISO_646.IRV:1991 US US-ASCII CSASCII
UTF-8
ISO-10646-UCS-2 UCS-2 CSUNICODE
UCS-2BE UNICODE-1-1 UNICODEBIG CSUNICODE11
UCS-2LE UNICODELITTLE
ISO-10646-UCS-4 UCS-4 CSUCS4
UCS-4BE
UCS-4LE
UTF-16
UTF-16BE