Skip to content

Instantly share code, notes, and snippets.

View arnekolja's full-sized avatar

Arne-Kolja Bachstein arnekolja

  • Germany/Lower Saxony/Wolfenbüttel
View GitHub Profile
@arnekolja
arnekolja / UncachedContent.php
Last active June 24, 2020 13:24
TYPO3 middleware to offer user login status as JSON for AJAX requests
<?php
namespace My\Ext\Middleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Http\Response;
@arnekolja
arnekolja / PartialExistsViewHelper.php
Last active October 14, 2018 01:38
TYPO3 Fluid ViewHelper to check if a partial name exists ("My/Partial")
<?php
namespace Krbu\Utility\ViewHelpers;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
/**
* Copyright note: Some parts are copied from the Fluid package.
* Usage example:
* <f:if condition="{krbu:PartialExists(partial: 'Category/{item.category.id}/DetailCol1')}">
@arnekolja
arnekolja / MyController.php
Created January 10, 2015 19:05
TYPO3, Extbase: Simple JsonView usage
<?php
/* This is tested with 6.2.9 only */
namespace MY\Extension\Controller;
class MyController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
private $ajaxPageType = 133799;
/**
@arnekolja
arnekolja / regex_typing_validation.js
Created October 22, 2010 14:35
Simplest way to allowing only given regular expressions in an input field. Uses jQuery for selecting the element though, you might want to change this.
$(document).ready( function() {
$("input.alphanumeric").keypress(function (e) {
if (String.fromCharCode(e.keyCode).search(/[0-9A-Za-z]/) == -1) return false;
});
$("input.numeric").keypress(function (e) {
if (String.fromCharCode(e.keyCode).search(/[0-9]/) == -1) return false;
});
});
/*
* Bookmarklet for viewing source in iPad Safari
*/
javascript:(function(){
var w = window.open('about:blank'),
s = w.document;
s.write('<!DOCTYPE html><html><head><title>Source of ' + location.href + '</title><meta name="viewport" content="width=device-width" /></head><body></body></html>');
s.close();

(This is the text of the keynote I gave at Startup Riot 2009. Will update when video becomes available.)

Hi everyone, I’m Chris Wanstrath, and I’m one of the co-founders of GitHub.

GitHub, if you haven’t heard of it, has been described as “Facebook for developers.” Which is great when talking about GitHub as a website, but not so great when describing GitHub as a business. In fact, I think we’re the polar opposite of Facebook as a business: we’re small, never took investment, and actually make money. Some have even called us successful.

Which I’ve always wondered about. Success is very vague, right? Probably even relative. How do you define it?

After thinking for a while I came up with two criteria. The first is profitability. We employ four people full time, one person part time, have thousands of paying customers, and are still growing. In fact, our rate of growth is increasing – which means January was our best month so far, and February is looking pretty damn good.

#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
#!/bin/bash
# This script saves all databases in one file per database
# without the need to enumerate them. It just fetches a list
# of all databases and iterates over this list.
# Config part
user="root";
pass="rootpassword";
backup_path="/var/backups";
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' > verzeichnisstruktur.txt