Skip to content

Instantly share code, notes, and snippets.

View TorbenKoehn's full-sized avatar

Torben Köhn TorbenKoehn

View GitHub Profile
@TorbenKoehn
TorbenKoehn / OwnScript.md
Created July 17, 2013 09:39
OwnScript Specification

OwnScript Specification

Introduction

What is OwnScript? ...you might ask. OwnScript is a programming language based on good parts of specific other languages, namely PHP, JavaScript, Java, Ruby and C#

{{ACTION}} = Die Aktion, die die PHP API empfangen soll
{{METHOD}} = Die HTTP Request Method (Meist GET für lesen, POST für schreiben)
{{GET_DATEN}} = Die GET Daten im Query String Format
{{POST_DATEN}} = Die POST Daten im Query String Format
//prepar request
NSString *urlString = [NSString stringWithFormat:@"http://deineurl.com/api.php?action={{ACTION}}&{{GET_DATEN}}"];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
<?php
/*
* Die Daten in $_GET befinden sich in der URL
* http://meine-domain.com/api.php?action=test&nocheins=test2
* Hier ist
* $_GET[ 'action' ] === 'test'
* $_GET[ 'nocheins' ] === 'test2'
*
* Die Daten vom POST request befinden sich im Request Body
@TorbenKoehn
TorbenKoehn / Autoboxing.php
Last active December 19, 2015 02:49
PHP Autoboxing: What it could look like I don't think, multiple autoboxing-functions make sense, a __autobox would indeed be more useful than spl_autobox_register, since you can't "merge" multiple classes defined on autoboxes and frameworks require specific functions. The best way would be enabling/disabling the autoboxing in frameworks, set it …
<?php
class Type {
protected $value;
public function __construct( $value ) { $this->value = $value; }
abstract public function __cast( /* (string) Class name */ $type );
}
@TorbenKoehn
TorbenKoehn / Path.php
Last active May 15, 2018 12:49
Path manipulation class for PHP frameworks (not fully tested)
<?php
namespace Dwarf;
class Path extends Object implements \IteratorAggregate, \Countable {
protected $path;
public function __construct( $path ) {
@TorbenKoehn
TorbenKoehn / array_column.php
Created June 26, 2013 09:40
Polyfill for the PHP 5.4 array_column() function (untested)
<?php
//Signature: array array_column ( array $input , mixed $column_key [, mixed $index_key ] )
if( !function_exists( 'array_column' ) ):
function array_column( array $input, $column_key, $index_key = null ) {
$result = array();
foreach( $input as $k => $v )
$result[ $index_key ? $v[ $index_key ] : $k ] = $v[ $column_key ];
@TorbenKoehn
TorbenKoehn / gist:5636266
Created May 23, 2013 13:58
x-jquery HTML Custom Element Test
<!-- This will produce a CORS error (expected) -->
<!--<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>-->
<element name="x-jquery">
<!-- This will produce a CORS error (expected) -->
<!--<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>-->
<template>
<!-- This won't load at all, even with content in the element -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>