Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="UTF-8"?>
<metrics files="33" functions="1" cls="37" clsa="2" clsc="35" roots="2" leafs="35" interfs="0" maxdit="2">
<file name="/Applications/xampp/xamppfiles/htdocs/eStudy_svn/web/emoderation/classes/webservice/class.webservicecache.inc.php" classes="1" functions="0" loc="190" cloc="41" ncloc="149" locExecutable="81" locExecuted="36" coverage="44.444444">
<class name="WebserviceCache" loc="162" locExecutable="81" locExecuted="36" aif="0.000000" ahf="100.000000" ca="0" ce="3" csz="21" cis="15" coverage="44.444444" dit="0" i="1.000000" impl="1" mif="0.000000" mhf="16.666667" noc="0" pf="0.000000" vars="3" varsnp="0" varsi="3" wmc="26" wmcnp="21" wmci="26">
<method name="__construct" loc="4" locExecutable="2" locExecuted="2" coverage="100.000000" ccn="1" crap="1.000000" npath="1" parameters="2"/>
<method name="get" loc="10" locExecutable="7" locExecuted="7" coverage="100.000000" ccn="2" crap="2.000000" npath="2" parameters="3"/>
<method name="set" loc=
@commana
commana / eopl_chapter1.scm
Created December 2, 2008 20:45
My solutions for chapter 1.4 of EOPL
; Int x Val -> List-of-Val
(define duple
(lambda (n x)
(duple-list-element n '() x)))
; Int x List x Val -> List
(define duple-list-element
(lambda (n lst x)
(if (zero? n)
lst
@commana
commana / gist:34843
Created December 11, 2008 19:56
Changes charset of files recursively
#!/bin/bash
ICONVBIN='/usr/bin/iconv' # path to iconv binary
ORIGINAL_IFS=$IFS
IFS=$'\n'
if [ $# -lt 3 ]
then
echo "$0 dir from_charset to_charset"
@commana
commana / compose.php
Created December 12, 2008 11:01
Compose in PHP 5.3
<?php
function compose($a, $b) {
return function ($x) use ($a, $b) {
return $a($b($x));
};
}
$F = function($x) { return $x; };
@commana
commana / utf8_code_migration.java
Created January 10, 2009 13:38
UTF-8 File Conversion for Windows
// Code by Anton Afanasjew
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
public class FileListExample {
public static final String CMD = "run.cmd";
@commana
commana / sites-available
Created February 24, 2009 16:45
sites-available-default for eStude Subversion and Trac
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost
Alias /trac "/usr/share/trac/htdocs"
ScriptAlias /estudy /usr/share/trac/cgi-bin/trac.cgi
<Location "/estudy">
SetEnv TRAC_ENV "/home/trac/estudy"
</Location>
<Location /svn>
DAV svn
AuthzSVNAccessFile /var/lib/svn/estudy/conf/authz
SVNParentPath /var/lib/svn
SVNAutoversioning on
AuthType Basic
AuthName "SVN - eStudy"
AuthUserFile /home/trac/estudy/estudy.htpasswd
Require valid-user
</Location>
<?php
class UberSingleton {
private $state = 0;
private static $instance;
private function __construct() {}
@commana
commana / mysql_myisam_to_innodb.php
Created July 29, 2009 16:43
A quick way to create all statements to migrate MyISAM tables to InnoDB
<?php
$sql = "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'estudy_v2' AND ENGINE = 'MyISAM'";
$tables = $db->get_col($sql);
foreach($tables as $tableName) {
echo "ALTER TABLE `$tableName` ENGINE = InnoDB ;\n";
}
@commana
commana / church_encoding.js
Created September 17, 2009 12:05
Church encoding in JavaScript
var inc = function (n) {
return n + 1;
};
var zero = function (f) {
return function (x) { return x; };
};
var church = function (n) {
var loop = function (n, acc) {