Skip to content

Instantly share code, notes, and snippets.

Stefan Lange Stoffo

  • @frnde GmbH
  • Hamburg, Germany
Block or report user

Report or block Stoffo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Stoffo
Stoffo / github_pull_request_check.sh
Last active May 8, 2019
Checks The GitHub API for Pull Requests to Review and changes the color of Anybar
View github_pull_request_check.sh
#!/usr/bin/env bash
GITHUB_USERNAME=
GITHUB_AUTH_TOKEN=
GITHUB_SEARCH_QUERY="is:open%20is:pr%20review-requested:Stoffo%20archived:false"
change_anybar_color () {
echo -n $1 | nc -4u -w0 localhost 1738
}
View keybase.md

Keybase proof

I hereby claim:

  • I am stoffo on github.
  • I am stoffo (https://keybase.io/stoffo) on keybase.
  • I have a public key ASCC5nWvlLdxecypFg5Romc7u2GSeEu7bZzCVk4iCF-5Gwo

To claim this, I am signing this object:

@Stoffo
Stoffo / TypeHintingArrayOfObjects.php
Last active Oct 12, 2016
PHPDoc type hinting for array of objects
View TypeHintingArrayOfObjects.php
<?php
interface CheckInterface
{
public function check();
}
/**
*
* @var $foo CheckInterfaceInterface[]
@Stoffo
Stoffo / palindrome.js
Last active Dec 10, 2015
Checks if String is a palindrome.
View palindrome.js
function palindrome(str) {
// Convert to lower case and replace everything what's not a letter or a number.
var x = str.toLowerCase().replace(/[^a-z0-9]/g, '');
//convert string to array, turn it around and put it back together an match it against filtered string:
return x.split('').reverse().join('') === x;
}
palindrome("eye");
@Stoffo
Stoffo / EcmaScript6_Examples.js
Created Dec 7, 2015
A few simple Examples in EcmaScript6 to play around with.
View EcmaScript6_Examples.js
const PI = 3.1415926535;
function foo(a = 123, b = '') {
return PI
}
function bar(a, b, c, ...x) {
return x.length;
View Detect visibility change of Browser Window in JavaScript
var defaultTitle = document.title;
// subscribe to visibility change events
document.addEventListener('visibilitychange', function () {
// fires when user switches tabs, apps, goes to homescreen, etc.
if (document.visibilityState === 'hidden') {
document.title = 'Baby, Come Back!'
}
// fires when app transitions from prerender, user returns to the app / tab.
if (document.visibilityState === 'visible') {
@Stoffo
Stoffo / counter_increment.html
Created Nov 23, 2015
A simple example how CSS Counters work
View counter_increment.html
<style>
ul {
counter-reset: foo;
}
li:before {
counter-increment: foo;
content: 'Count: ' counter(foo);
}
</style>
@Stoffo
Stoffo / detect_arrow_keys.js
Last active Oct 29, 2015
simple event handler to map keycodes of arrow keys to functions.
View detect_arrow_keys.js
$(window).on('keyup', function (e) {
switch (e.keyCode) {
/*left*/
case 37:
console.log('left');
break;
/*right*/
case 39:
console.log('right');
break;
@Stoffo
Stoffo / remove_documents_mongodb.js
Created Oct 29, 2015
Remove Documents older than x days in MongoDB
View remove_documents_mongodb.js
var date = new Date();
var daysToDeletion = 120;
var deletionDate = new Date(date.setDate(date.getDate() - daysToDeletion));
printjson(deletionDate);
var db = db.getSiblingDB('db')
db.getMongo().setSlaveOk();
printjson(db.messages.find({insertDate : {$lt : deletionDate}}).count());
@Stoffo
Stoffo / twig_file_date_extension.php
Last active Oct 30, 2018
Twig Function to get the file mtime in template for HTTP Caching
View twig_file_date_extension.php
<?php
$function_filedate = new Twig_SimpleFunction(
'fileDate',
/**
* @param $file_path
* This function generates a new file path with the last date of filechange
* to support better better client caching via Expires header:
* i.e:
You can’t perform that action at this time.