Skip to content

Instantly share code, notes, and snippets.

@codler
codler / gist:645911
Created October 25, 2010 22:21
Javascript Regex
// strip multiline comment
.replace(/\/\*((?:[^\*]|\*[^\/])*)\*\//g, '')
# -*- encoding: utf8 -*-
#
# Simple WebSockets in Python
# By Håvard Gulldahl <havard@gulldahl.no>
#
# Based on example by David Arthur (he did all the hard work :)
# https://gist.github.com/512987
#
import struct
@codler
codler / gist:845809
Created February 27, 2011 01:18
wget.exe
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;
public class wget
{
@codler
codler / gist:906181
Created April 6, 2011 18:10
relative_date
/**
* Convert to relative date
*
* @param int $timestamp In seconds
* @param array $settings
* @param string $default_format
* @return string
* @version 1.0 (2011-12-12)
*/
function relative_date( $timestamp, array $settings = array(), $default_format = 'Y-m-d' ) {
@codler
codler / gist:1024805
Created June 14, 2011 12:30
Screen capture
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.Runtime.InteropServices;
// Made By Han Lin Yap 2011-03-03
public class screen_capture
@codler
codler / gist:1323293
Created October 28, 2011 19:40 — forked from fat/gist:1217433
tabs with history support
/* ========================================================
* bootstrap-tab.js v2.0.1 modified r1
* http://twitter.github.com/bootstrap/javascript.html#tabs
* ========================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
<script>
var queue = 0;
var last_index = 0;
jQuery(function ($) {
$(document).on('click', '#splash .left a', function () {
show_splash(--last_index);
return false;
});
$(document).on('click', '#splash .right a', function () {
@codler
codler / gist:1481867
Created December 15, 2011 17:01
Glesys API
<?php
$username = 'clXXXXX';
$password = '';
$base_url = 'https://api.glesys.com';
$param = '/server/list/format/json/';
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$password")
@codler
codler / convert_ascii.php
Created December 20, 2011 09:37 — forked from jaywilliams/convert_ascii.php
This simple function will remove any non-ASCII character. Feel free to fork and extend!
<?php
/**
* Remove any non-ASCII characters and convert known non-ASCII characters
* to their ASCII equivalents, if possible.
*
* @param string $string
* @return string $string
* @author Jay Williams <myd3.com>
* @license MIT License
* @link http://gist.github.com/119517
@codler
codler / proxy.php
Created May 1, 2012 14:58
Simple PHP Proxy
<?php
/**
* @author Han Lin Yap < http://zencodez.net/ >
* @copyright 2012 zencodez.net
* @license http://creativecommons.org/licenses/by-sa/3.0/
* @package proxy
* @version 1.0 - 2012-05-01
*/
$method = $_SERVER['REQUEST_METHOD'];
$request = substr($_SERVER['PATH_INFO'], 1);