Skip to content

Instantly share code, notes, and snippets.

View v6ak's full-sized avatar

Vít Šesták v6ak

View GitHub Profile
// DOCUMENTATION FAIL:
/**
* Alias for {@link #set(Object)}
*/
@Override
public void set(T value) {
setValue(value);
};
@v6ak
v6ak / NaturalComparator.java
Created March 2, 2010 19:36
example of a reasonable Singleton
package v6ak.util;
import java.util.Comparator;
public final class NaturalComparator {
private static final Comparator<? extends Comparable<?>> instance = new Comparator<Comparable<Object>>(){
public int compare(Comparable<Object> o1, Comparable<Object> o2) {
if( o1==null || o2==null ){
throw new NullPointerException("Comparing null values is not supported!");
@v6ak
v6ak / identity.php
Created March 4, 2010 10:02
PHP zval experiments
<?php
final class v6_Variable{
private $val;
public function set($val){
$this->val = $val;
}
#include <stdio.h>
#include <stdlib.h>
typedef int boolean;
///////////// abstract CharProcessor ///////////////////////////////////
typedef struct _CP{ // abstract
/*public abstract*/ struct _CP* (*nextFunction) (struct _CP *this, char c, FILE *out);
/*public virtual*/ void (*destroyFunction) (struct _CP *this);
/*private field*/ boolean canBeFinal;
package v6.micro.platforms;
public final class Platform {
private static final String JP_PREFIX = "JP-";
private Platform() {}
public static boolean isA200OrHigher() {
return isA200OrHigher(System.getProperty("com.sonyericsson.java.platform"));
@sh "%~pd0port.sh" %*
<?php
/**
* Representation of enumerated grid column.
*
* @author Vít Šesták 'v6ak'
* @copyright Copyright (c) 2010 Vít Šesták
* @license New BSD License
* @package Nette\Extras\DataGrid
*/
<?php // taková funkcionální pochoutka...
$expcook = explode('; ', $cookiesString);
$lincook = array_map(function($v){return explode('=', $v, 2);}, $expcook);
$cookies = array_combine(array_map(function($v){return $v[0];}, $lincook), array_map(function($v){return $v[1];}, $lincook));
@v6ak
v6ak / fragment-rc.xml
Created September 8, 2010 14:30
Switching tray in Openbox
<keybind key="W-t">
<action name="Execute">
<startupnotify>
<enabled>true</enabled>
<name>qwitch tint</name>
</startupnotify>
<command>~/bin/switchTray</command>
</action>
</keybind>
<?php
// PHP fragment
// Code creates a multicomponent in Nette. The code is a bit ugly.
protected function createComponent($name){
$PFX = 'rating';
$PFXLEN = strlen($PFX);
if(substr($name, 0, $PFXLEN === $PFX){
return $this->createRating($name, substr($name, $PFXLEN));
}