Skip to content

Instantly share code, notes, and snippets.

View thelebster's full-sized avatar
:octocat:
Do nothing, it is ok.

Anton Lebedev thelebster

:octocat:
Do nothing, it is ok.
View GitHub Profile
@thelebster
thelebster / git-php-webhook.php
Created April 20, 2016 07:37 — forked from marcelosomers/git-php-webhook.php
A basic webhook for deploying updates to repos on Github to your local server
<?php
/**
* This script is for easily deploying updates to Github repos to your local server. It will automatically git clone or
* git pull in your repo directory every time an update is pushed to your $BRANCH (configured below).
*
* Read more about how to use this script at http://behindcompanies.com/2014/01/a-simple-script-for-deploying-code-with-githubs-webhooks/
*
* INSTRUCTIONS:
* 1. Edit the variables below
* 2. Upload this script to your server somewhere it can be publicly accessed
@thelebster
thelebster / install_drupal_env.sh
Created April 21, 2016 08:05 — forked from otarza/install_drupal_env.sh
Drupal Environment
#!/usr/bin/env bash
# Use single quotes instead of double quotes to make it work with special-character passwords
PASSWORD='12345678'
PROJECTFOLDER='gdson'
# create project folder
sudo mkdir "/sites/${PROJECTFOLDER}"
# update / upgrade
@thelebster
thelebster / patch_apply_remove
Created April 21, 2016 08:05 — forked from reli/patch_apply_remove
Drupal patch
apply
patch -p1 < path/file.patch
remove
patch -p1 -R < path/file.patch
@thelebster
thelebster / Git push deployment in 7 easy steps.md
Created April 21, 2016 08:06 — forked from thomasfr/Git push deployment in 7 easy steps.md
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@thelebster
thelebster / github_post_recieve.php
Created April 21, 2016 08:06 — forked from cowboy/github_post_recieve.php
GitHub PHP webhook to auto-pull on repo push
<?php
// Use in the "Post-Receive URLs" section of your GitHub repo.
if ( $_POST['payload'] ) {
shell_exec( 'cd /srv/www/git-repo/ && git reset --hard HEAD && git pull' );
}
?>hi
@thelebster
thelebster / email_dreamcode.js
Created June 7, 2016 09:32 — forked from gr2m/email_dreamcode.js
Imagine you could send emails with JavaScript, multipart, and with attachments?! How would the code look like? This is what I came up with. Forks & comments much appreciated! #nobackend #dreamcode
// send text email
sendEmail({
subject: "Hello, World!",
text: "This mail has been sent from the frontend",
to: "[email protected]"
})
// send multipart text / html email
sendEmail({
subject: "Hello, World!",
@thelebster
thelebster / dbconversion.php
Created October 17, 2016 05:39 — forked from sanjaybhowmick/dbconversion.php
Convert MySQL collation from utf8mb4 to utf8
<?php
$dbname = 'your-database-name';
mysql_connect('your-database-hostname', 'your-database-username', 'your-database-password');
mysql_query("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
$result = mysql_query("SHOW TABLES FROM `$dbname`");
while($row = mysql_fetch_row($result)) {
$query = "ALTER TABLE {$dbname}.`{$row[0]}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci";
mysql_query($query);
$query = "ALTER TABLE {$dbname}.`{$row[0]}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
mysql_query($query);
@thelebster
thelebster / ImageRenderExampleBlockByURI.php
Created October 20, 2016 10:40 — forked from jerbob92/ImageRenderExampleBlockByURI.php
Render image into a block Drupal 8 Example by URI
<?php
/**
* @file
* Contains Drupal\mymodule\Plugin\Block\ImageRenderExampleBlockByURI.
*/
namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;
@thelebster
thelebster / d8-responsive-image-programmatically.php
Created October 21, 2016 10:45 — forked from szeidler/d8-responsive-image-programmatically.php
Load and render responsive image from field in Drupal 8
<?php
function _load_header_image($variables) {
if ($node = $variables['node']) {
// Load main_image
$file = $node->field_main_image->entity;
if ($file) {
$variables = array(
'responsive_image_style_id' => 'header_image',
'uri' => $file->getFileUri(),