Skip to content

Instantly share code, notes, and snippets.

View saksmt's full-sized avatar

Kirill Saksin saksmt

View GitHub Profile
@saksmt
saksmt / ChatController.php
Created September 5, 2014 07:11
Variable definition? I don't need it...
private function calculateDuration($startTime)
{
$currTime = time();
$diff = $currTime - $startTime;
if ($diff >= 3600) {
// hours
$difference = $diff/3600;
$difference = round($difference,0);
if ($difference>1) { $extra="s"; }
package com.smt.todo.model;
public class UnitOfWork {
private static UnitOfWork soleInstance = null;
private FinderInterface finder;
public static UnitOfWork getInstance() {
UnitOfWork.initialize();
return UnitOfWork.soleInstance;
@saksmt
saksmt / gist:baebd25deca65a792aee
Created October 1, 2014 09:40
Java: get all implementations of interface
interface Interface {}
class InterfaceImpl1 implements Interface {}
class InterfaceImpl2 implements Interface {}
class Main {
private static List<Class<? extends Interface>> interfaceImplementations;
static {
interfaceImplementations = new ArrayList(Interface.class.getClasses()); // <- Doesn't work :(
}
@saksmt
saksmt / clock.js
Created December 9, 2014 18:36
Clock for Browser(Usefull with 2 monitors)
(function (window) {
'use stict';
/**
* Replaces "{slug}" with specified values, provided by argument
* @brief Set's slugs in string
* @param {Object} slugValues Map "slugName:slugValue"
* @returns {String}
*/
String.prototype.setSlugs = function (slugValues) {
var
@saksmt
saksmt / README.md
Created December 21, 2014 00:37
Flac(cue) splitting commandline utility

music-splitter

Simple commandline utility providing support for reqursively walk through all music directories and split large .flac files.

Requirements

Any linux distribution with split2flac, php and find.

@saksmt
saksmt / ObjectOriented.js
Created February 26, 2015 22:39
Extension for JavaScript providing object oriented feature
(function (global) {
'use strict';
/**
* @return {Function} Abstract function placeholder
*/
Function.prototype.makeAbstract = function () {
return function () {
throw new Error('Abstract method can\'t be called.');
};
};
@saksmt
saksmt / TableRendererInterface.php
Last active August 29, 2015 14:17
Abstraction on table rendering
<?php
/**
* @example
* $htmlRenderer = new HtmlRenderer();
* $consoleRenderer = new ConsoleRenderer();
* $htmlRenderer->renderToFile($view, 'some.html', [ TableRendererInterface::STREAMED ]);
* echo $consoleRenderer->renderToString($profilingView);
*/
interface TableRendererInterface
#
# Gentoo Linux
#
CONFIG_GENTOO_LINUX=y
CONFIG_GENTOO_LINUX_UDEV=y
#
# Support for init systems, system and service managers
#
# CONFIG_GENTOO_LINUX_INIT_SCRIPT is not set
@saksmt
saksmt / CodeStyle.md
Last active August 29, 2015 14:26
Java Code Style (B52)

Именование

Общий Стиль

Никакие сокращения не допускаются.

Именование должно быть таким, что код легко понять и без коментариев.

/**
* @param ${TYPE_HINT} $${PARAM_NAME}
#if (${STATIC} != "static")
* @return ${CLASS_NAME} This instance
#end
*/
#set($TYPE_HINT = $TYPE_HINT.replaceAll("(int(eger)?)|(bool(ean)?)|(string)|object|mixed", ""))
#if (${TYPE_HINT} != "")
#set($TYPE_HINT="${TYPE_HINT} ")
#end