Skip to content

Instantly share code, notes, and snippets.

Avatar

Vít Šesták v6ak

View GitHub Profile
View documentation-fail.java
// DOCUMENTATION FAIL:
/**
* Alias for {@link #set(Object)}
*/
@Override
public void set(T value) {
setValue(value);
};
@v6ak
v6ak / NaturalComparator.java
Created Mar 2, 2010
example of a reasonable Singleton
View NaturalComparator.java
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 Mar 4, 2010
PHP zval experiments
View identity.php
<?php
final class v6_Variable{
private $val;
public function set($val){
$this->val = $val;
}
View parse.c
#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;
View Platform.java
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"));
View EnumColumn.php
<?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
*/
View cookies-parser.php
<?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 Sep 8, 2010
Switching tray in Openbox
View fragment-rc.xml
<keybind key="W-t">
<action name="Execute">
<startupnotify>
<enabled>true</enabled>
<name>qwitch tint</name>
</startupnotify>
<command>~/bin/switchTray</command>
</action>
</keybind>
View actual.php
<?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));
}