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; }
@fabianmarz
fabianmarz / potx.sh
Last active April 13, 2018 10:22
Generate and move Drupal translation files to related folder via potx.
#!/bin/bash -eux
CURRENT_DIR=${PWD}
NAME="$(basename $CURRENT_DIR)"
DOCROOT=$(drush dd)
FILEPATH=$(realpath --relative-to="$DOCROOT" "$CURRENT_DIR")
drush potx --api=8 --folder=$FILEPATH/*
mkdir -p ./translations
mv $DOCROOT/general.pot ./translations/$NAME.pot
@nepsilon
nepsilon / auto-backup-your-configuration-files-with-vim.md
Last active October 22, 2024 22:10
Auto-backup your configuration files with Vim — First published in fullweb.io issue #71

Auto-backup your configuration files with Vim

Not using versioning on your configuration files and editing them with Vim?

Use Vim’s backup option to automatically keep a copy of past versions. To put in your ~/.vimrc:

"Turn on backup option
set backup
@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
@growdev
growdev / gist:b68e35b5c6e0856bdbf1
Created March 19, 2015 19:01
Delete all WooCommerce Products with wp-cli
wp post list --field=ID --post_type=product | xargs wp post delete --force
@sun
sun / config-dev.patch
Last active August 29, 2015 13:59
D8 config in files for development
diff --git a/sites/default/settings.php b/sites/default/settings.php
index b2ce930..9d0514e 100644
--- a/sites/default/settings.php
+++ b/sites/default/settings.php
@@ -611,7 +611,8 @@
* The 'bootstrap_config_storage' setting needs to be a callable that returns
* core.services.yml.
*/
- # $settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage');
+$settings['bootstrap_config_storage'] = 'Drupal\Core\Config\BootstrapConfigStorageFactory::getFileStorage';
alias.ssave=stash save
alias.sshow=!f() { git stash show stash^{/$*} -p; }; f
alias.sapply=!f() { git stash apply stash^{/$*}; }; f
alias.assume=update-index --assume-unchanged
alias.unassume=update-index --no-assume-unchanged
alias.assumed=!git ls-files -v | grep ^h | cut -c 3-
alias.masterdiff=log --oneline --no-merges --reverse master ^HEAD
alias.staged=diff --staged
alias.amend=commit --amend
alias.graph=log --oneline --graph --color=auto
<?php
require './core/vendor/autoload.php';
use Symfony\Component\Yaml\Parser;
function quantile($values, $p) {
sort($values);
$H = (count($values) - 1) * $p + 1;
$h = floor($H);
$v = $values[$h - 1];
@jareware
jareware / SCSS.md
Last active April 11, 2025 18:25
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@davereid
davereid / gist:4639015
Last active December 11, 2015 18:08
Entity operation automation
<?php
function entity_get_operation_links($entity_type, $entity, $base_path = NULL) {
$build = array(
'#theme' => 'links__operations__' . $entity_type,
'#links' => array(),
'#attributes' => array('class' => array('links inline')),
);
list($entity_id) = entity_extract_ids($entity_type, $entity);