Skip to content

Instantly share code, notes, and snippets.

@Cacodaimon
Cacodaimon / TestJs.js
Last active December 10, 2015 18:38
Quick comparison between TypeScript and JavaScript, with a semantic error (sub method missing in Vector3 class). Used @ cacodaemon.de
function Vector2(x, y) {
this.x = x ? x : 1;
this.y = y ? y : 1;
this.add = function(vector2) {
return new Vector2(this.x + vector2.x, this.y + vector2.y);
};
this.sub = function(vector2) {
return new Vector2(this.x - vector2.x, this.y - vector2.y);
@Cacodaimon
Cacodaimon / convert.php
Last active December 15, 2015 01:49
Converts the questions from the "OCA Java SE 7 Programmer 1 Study Guide (Exam 1Z0-803)" book CD into a readable JSON format. The dBASE files from the book disc have to be exported to a csv file first.
<?php
/**
* Converts the questions from the "OCA Java SE 7 Programmer 1 Study Guide (Exam 1Z0-803)" book CD into a readable JSON format.
* The dBASE files from the book disc have to be exported to a csv file first.
*
* @autor Guido Krömer <[email protected]>
*/
$fileQuestions = 'Questions.csv';
$fileAnswers = 'Answers.csv';
@Cacodaimon
Cacodaimon / index.html
Created July 23, 2013 11:31
Quick and dirty Google Feed API example, fetching the first image of each feed item.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Google Feed API JSONP Example displaying some Images - wwww.cacodaemon.de</title>
<script type="text/javascript">
function processResults (response) {
var entries = response.responseData.feed.entries;
var images = document.getElementById('images');
@Cacodaimon
Cacodaimon / Mcrypt.php
Last active December 24, 2015 04:29
Easy to use Mcrypt wrapper class.
<?php
namespace Caco\Password;
/**
* Mcrypt wrapper class.
*
* @author Guido Krömer <[email protected]>
* @package Caco\Password
*/
class Mcrypt
@Cacodaimon
Cacodaimon / validate_by_docblock
Created October 24, 2013 11:38
Quick and dirtyphp docblock based validation prototype...
<?php
abstract class Validate
{
public abstract function isValid($value);
}
class ValidateInt extends Validate
{
public function isValid($value)
@Cacodaimon
Cacodaimon / SumByKey.js
Created November 4, 2013 21:12
A simple AngularJS filter for summarizing the values of an array containing objects by a key.
angular.module('caco.feed.filter', [])
.filter('sumByKey', function() {
return function(data, key) {
if (typeof(data) === 'undefined' || typeof(key) === 'undefined') {
return 0;
}
var sum = 0;
for (var i = data.length - 1; i >= 0; i--) {
sum += parseInt(data[i][key]);
@Cacodaimon
Cacodaimon / SlimJsonView.php
Created November 5, 2013 15:42
Tiny slim json view.
class SlimJsonView extends \Slim\View
{
public function render($template = null)
{
$app = \Slim\Slim::getInstance();
!$this->has('error') && $this->data->remove('flash');
!$this->has('flash') && $this->data->remove('flash');
$app->response()->header('Content-Type', 'application/json');
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"font_face": "DroidSansMono",
"font_size": 12,
"highlight_line": true,
"highlight_modified_tabs": true,
"line_padding_bottom": 1,
"line_padding_top": 1,
"spell_check": true,
"tab_size": 4,
#!/bin/bash
HISTCONTROL=ignoreboth
shopt -s histappend
HISTSIZE=10000
HISTFILESIZE=20000
export EDITOR=nano
alias ls='ls --color'
alias ll='ls -lah'
alias ssh='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
@Cacodaimon
Cacodaimon / key-bindings-user.json
Created March 1, 2014 12:49
SublimeText3 german keyboard show console keybinding.
[
{ "keys": ["ctrl+^"], "command": "show_panel", "args": {"panel": "console", "toggle": true} }
]