Skip to content

Instantly share code, notes, and snippets.

class Singleton
{
private static $_instance;
private function __construct() {}
private function __clone() {}
public static function getInstance()
{
class Hello {
public static void main(String args[]) {
System.out.print("Hello, world");
}
}
@edwinschaap
edwinschaap / vps-clean-debian-ubuntu.sh
Created February 16, 2011 20:02
This scripts cleans up some mess from the default Ubuntu 10.10 (32bits)installation done by prefiber. Can be used on debian (not tested).
#!/bin/bash
function print_info {
echo -n -e '\e[1;36m'
echo -n $1
echo -e '\e[0m'
}
function print_warn {
@edwinschaap
edwinschaap / skeleton.xq
Created March 11, 2011 09:49
twitter skeleton excerise
declare function fetch-tweets($keyword as xs:string) as node()* {
let $uri := "http://search.twitter.com/search.atom?geocode=52.1583,4.49306,200km&rpp=100&q=XXX"
return (: TODO replace XXX by keyword, fetch real entrys with doc() from uri :)
<entry><title>oops, I did it again</title><uri>http://twitter.com/britneyspears</uri><location>Hollywood</location></entry>
};
declare function get-geo($placename as xs:string) as xs:string {
let $uri := (:replace XXX by placename :)
"http://where.yahooapis.com/v1/places.q(&quot;XXX&quot;);count=1?format=xml&amp;appid=oWI.U034EMJO6CnsA4vFEvJ5oYEKsoD0qLIRfcoEKOLLTqv9bh6jBHZn9GhdRA--",
$centroid :=
module namespace tweetmap = "tweetmap";
declare function tweetmap:fetch-tweets($keyword as xs:string) as node()* {
let $baseuri := "http://search.twitter.com/search.atom?geocode=52.1583,4.49306,200km&amp;rpp=100&amp;q="
let $uri := concat($baseuri, $keyword)
return doc($uri)//*:feed//*:entry
};
declare function tweetmap:get-geo($placename as xs:string) as xs:string {
@edwinschaap
edwinschaap / genAccessToken.php
Created March 16, 2012 14:33
generate access token
<?php
protected function genAccessToken() {
return md5(base64_encode(pack('N6', mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), uniqid())));
}
@edwinschaap
edwinschaap / SzovegType.php
Created December 11, 2012 11:07
example form class in Silex
<?php
namespace Insolis\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
class SzovegType extends AbstractType
{
@edwinschaap
edwinschaap / index.html
Last active December 16, 2015 16:59
d3.js visual approach
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>d3.js - Top 10 used words</title>
<script type="text/javascript" src="http://mbostock.github.io/d3/d3.v2.js?2.9.5"></script>
<style type="text/css">
.chart div {
font: 10px sans-serif;
background-color: steelblue;
text-align: right;
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<div id="map" style="width:100%px;height:400px;" class="google_map full"></div>
<script type="text/javascript">
var latlng = new google.maps.LatLng(0, 0);
var myOptions = {
zoom: 16,
center: latlng,
scrollwheel: true,
scaleControl: false,
disableDefaultUI: false,
alert('boo')