Skip to content

Instantly share code, notes, and snippets.

View sun's full-sized avatar
👌
Happy

Daniel Kudwien sun

👌
Happy
View GitHub Profile
@sun
sun / ard-zdf-live-tv-stream-maximize-bookmarklet.js
Last active December 13, 2020 20:54
Maximizes ARD/ZDF live TV player without entering fullscreen; allows window switching and better performance for watching e.g. football world championship in the background. Copy code into a bookmark and click the bookmark to toggle the player size on http://www.daserste.de/live/index.html and https://www.zdf.de/live-tv#/beitrag/livevideo/182260…
javascript:(function () {
if (!document.getElementById('sun-maxplayer')) {
var style = document.createElement('style');
style.type = 'text/css';
style.id = 'sun-maxplayer';
style.appendChild(document.createTextNode('
/* ZDF */
html .page #skip-main .b-playerbox { width: 100vw; z-index: 999999999; transform: translate3d(-341.9px, 0px, 0px); }
html .page .scroll-arrow { display: none; }
html .b-header { position: static; }
@sun
sun / .gitconfig
Created March 2, 2018 08:39
netzstrategen git config
[user]
name = Firstname Lastname
email = firstname@netzstrategen.com
[core]
autocrlf = false
safecrlf = false
ignorecase = false
excludesfile = ~/.gitignore
[fetch]
prune = true
@sun
sun / custom.views_execution.inc
Created February 28, 2018 20:31
How to exclude nodes on a single page that were output in a previous view already?
<?php
/**
* Gets queried node IDs and store them in a static variable.
*
* Implements hook_views_post_execute().
*/
function custom_views_post_execute($view) {
if ($view->id() !== 'taxonomy_term') {
return;
@sun
sun / functions.php
Created October 23, 2017 16:28
Put the following files into a 'flatsome-child' folder: http://codex.wordpress.org/Child_Themes
<?php
require get_template_directory() . '/inc/init.php';
@sun
sun / functions.php
Last active June 7, 2017 12:46
WordPress: How to add a namespace to procedural code (see diff between revisions)
<?php
namespace Vendor\Mine;
function hook_name($value) {
return $value;
}
add_filter('hook_name', __NAMESPACE__ . '\hook_name');
@sun
sun / 0_reuse_code.js
Created April 14, 2016 01:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sun
sun / vim-cheatsheet.py
Last active January 30, 2020 13:53
vim
# Replace `define('...', '...');` with `const ... = ...;`
:%s/define( *'\(\w*\)',\( *\)'\([^']*\)' *);/const \1 =\2'\3';/
# Replace `isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] :` with `$_SERVER['SERVER_NAME'] ??`
# Using different delimiters to match an underscore literally.
:%s!isset.*SERVER_NAME.*:!$_SERVER['SERVER_NAME'] ??!
# Convert line endings to Linux/Unix
:set ff=unix
### Keybase proof
I hereby claim:
* I am sun on github.
* I am sun (https://keybase.io/sun) on keybase.
* I have a public key whose fingerprint is 1292 4213 3E34 D0B0 68A6 DE4D 0AA6 11AF B3CA F936
To claim this, I am signing this object:
@sun
sun / bug.php
Last active August 29, 2015 14:04
SplDoublyLinkedList::IT_MODE_LIFO unsets wrong key
<?php
$list = new SplDoublyLinkedList();
// Comment this out to make it behave.
$list->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
$list->push('one');
$list->push('two');
foreach ($list as $key => $value) {
@sun
sun / bench.loop.php
Last active August 29, 2015 14:04
Bench various ways of natively looping over PHP arrays
<?php
# Simple PHP 5.4+ bench script for CLI.
const ITERATIONS = 1000;
const ARRAY_SIZE = 1000;
define('CONDITION', 'item' . (ARRAY_SIZE - 1));
error_reporting(E_ALL | E_STRICT);
setlocale(LC_ALL, 'C');
register_shutdown_function(function () {