Skip to content

Instantly share code, notes, and snippets.

@jleehr
jleehr / form_style.scss
Last active January 20, 2016 10:03
HTML form radio and checkbox style
input {
&+ label {
line-height: 1.2em;
}
/* Checkboxes */
&[type="checkbox"] {
display: none;
&:checked + label:before {
@jleehr
jleehr / ContainsNumeric.php
Created January 27, 2016 12:34
Symfony 2 - Custom validator
<?php
namespace AppBundle\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
/**
* @Annotation
*/
class ContainsNumeric extends Constraint
@jleehr
jleehr / restore.php
Last active September 15, 2016 14:06
Restore lost files in git
#!/bin/bash
# 1. git fsck --lost-found
# 2. run this script via bash restore.php
cd PATH_TO/.git/lost-found/other
FILES=*
COUNTER=0
for f in $FILES; do
echo "Processing $f file..."
git show $f > "PATH_TO/recover/$COUNTER.txt"
@jleehr
jleehr / domcheck.js
Last active August 11, 2022 22:42
Detection if an element is added to DOM
// Detection if an element is added to DOM
function onElementInserted(containerSelector, elementSelector, callback) {
var onMutationsObserved = function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
var elements = $(mutation.addedNodes).find(elementSelector);
for (var i = 0, len = elements.length; i < len; i++) {
callback(elements[i]);
}
}
@jleehr
jleehr / Readme.md
Last active June 30, 2017 07:49
Configuring Git over SSH to login once

MsysGit or Cygwin

Add a file called .bashrc to your home folder. Open the file and paste in:

#!/bin/bash
eval `ssh-agent -s`
ssh-add

# Stop ssh-agent if session is closed.
@jleehr
jleehr / README.md
Last active August 13, 2020 13:59
[Drupal 8] Alter route (permissions) for taxonomy vocabulary page

[Drupal 8] Alter route (permissions) for taxonomy vocabulary page

Needs the patch: https://www.drupal.org/node/1848686

Split "Administer vocabularies and terms" permission: Access the taxonomy overview page and Add terms in vocabulary name

File structure:

mymodule
|- src
@jleehr
jleehr / gist:9aaebcc54e683b96536689b30510efac
Last active February 9, 2018 11:20
Php Code Sniffer + Drupal
Global Coder Install
$ composer global require drupal/coder
PHPCS zur Pfadvariable hinzufügen in ~/.profile, ~/.bash_profile oder ~/.bashrc
export PATH="$HOME/AppData/Roaming/Composer/vendor/bin:$PATH"
Standards registrieren
$ phpcs --config-set installed_paths C:\Users\[USER]\AppData/Roaming/Composer/vendor/drupal/coder/coder_sniffer
Prüfung durchführen mit
@jleehr
jleehr / gist:7ac2a5de785881dfce99f7034547f07b
Last active May 25, 2023 11:02
Drupal 8 - Migrate from public to private files
# Enable maintanance mode
drush state-set system.maintenance_mode 1
# Backup file field data
drush sql-query "CREATE TABLE media__field_file_bak AS SELECT * FROM media__field_file;"
drush sql-query "CREATE TABLE media_revision__field_file_bak AS SELECT * FROM media_revision__field_file;"
# Truncate file field tables (need to change storage settings)
drush sql-query "TRUNCATE media__field_file;"
drush sql-query "TRUNCATE media_revision__field_file;"
@jleehr
jleehr / .blackfire.env
Last active June 8, 2021 13:43
Blackfire.io & Lando
####
## Blackfire config - `lando rebuild` required
####
BLACKFIRE_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
BLACKFIRE_CLIENT_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BLACKFIRE_SERVER_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
BLACKFIRE_SERVER_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@jleehr
jleehr / JSON.py
Created November 18, 2020 15:06
BBEdit Text actions
#!/usr/bin/python
import fileinput
import json
print json.dumps( json.loads(''.join([line.strip() for line in fileinput.input()])), sort_keys=True, indent=2)