Skip to content

Instantly share code, notes, and snippets.

View nevergone's full-sized avatar

Kurucz István nevergone

View GitHub Profile
@calebporzio
calebporzio / composer_versions_cheatsheet.md
Last active September 30, 2024 08:58
Composer version symbol cheatsheet
...
"require": {
    "vendor/package": "1.3.2", // exactly 1.3.2 (exact)

    // >, <, >=, <= | specify upper / lower bounds
    "vendor/package": ">=1.3.2", // anything above or equal to 1.3.2
    "vendor/package": "<1.3.2", // anything below 1.3.2

 // * | wildcard
@chx
chx / services-grep
Last active September 11, 2017 18:21
services-grep
ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))' $2 | \
jq -Mr --arg name "$1" '.services | keys[] as $k | .[$k] | select(.tags[]?.name == $name) | $k'
# ag -l -G '.services.yml$' access_check| while read filename ;do services-grep access_check "$filename" ;done
@bdlangton
bdlangton / Blocks.md
Last active February 3, 2026 12:41
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
@dantleech
dantleech / README.md
Last active October 21, 2021 21:22
PHPStan Drupal Integration
$ composer require phpstan/phpstan

Drupal dynamically adds to the class autoloader at runtime, so it is necessary to bootstrap Drupal in order that it is fully populated. Note that this may require that the database be accessible (i.e. may be problematic when working with Docker). This is why we use a custom autoload file below.

$ ./bin/phpstan analyse --level=7 -c phpstan.neon docroot/modules/custom
@icetee
icetee / permissions.sh
Created September 12, 2018 16:27 — forked from heyalexej/permissions.sh
Fix WordPress File Permission
#!/bin/bash -ex
#
# configures wordpress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# script is aware of .git directories by default. edit if you need to consider
# other folders as well.
#
# you will find a log file in /tmp/ in case you fucked up.
@mistic100
mistic100 / vimeo-downloader.js
Created September 15, 2018 09:01
Download video from Vimeo (chopped m4s files)
// 1. Open the browser developper console on the network tab
// 2. Start the video
// 3. In the dev tab, locate the load of the "master.json" file, copy its full URL
// 4. Run: node vimeo-downloader.js "<URL>"
// 5. Combine the m4v and m4a files with mkvmerge
const fs = require('fs');
const url = require('url');
const https = require('https');
@chx
chx / Table.php
Created December 6, 2018 21:02
Plain table migration source plugin
<?php
namespace Drupal\sd8_migration\Plugin\migrate\source;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
/**
* Table source from database.
*
Age 6, 7:
- Print their name or any string of their choice.
- Flashing Heart - https://makecode.microbit.org/projects/flashing-heart
- Snowflake - https://makecode.microbit.org/lessons/snowflake-fall
- Smiley - https://makecode.microbit.org/lessons/smiley
- Rock paper scissor basic - https://makecode.microbit.org/projects/rock-paper-scissors
- Banana Orange Keyboard - https://makecode.microbit.org/projects
- Magic 8 ball - https://makecode.microbit.org/lessons/magic-8
- Song: Happy Birthday - https://makecode.microbit.org/lessons/happy-birthday
@rwohleb
rwohleb / custom_util.post_update.php
Created November 20, 2019 04:11
Drupal 8: Convert text field to paragraph
<?php
use Drupal\Core\Utility\UpdateException;
use Drupal\paragraphs\Entity\Paragraph;
/**
* Convert news,blog,event body field to paragraphs.
*/
function custom_util_post_update_convert_newsblogevent_body(&$sandbox) {
@ozin7
ozin7 / Controller.php
Last active March 7, 2024 17:56
Drupal 8: Dependency injection in Service, Controller, Plugin, Deriver.
<?php
/**
* Controller. Implements ContainerInjectionInterface
*/
namespace Drupal\gurei\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\gurei\Service\CompanyService;
use Symfony\Component\DependencyInjection\ContainerInterface;