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 / drush-compare-modules.sh
Created October 22, 2016 05:45 — forked from szeidler/drush-compare-modules.sh
Make enabled modules diff of two drupal installations
diff -u <(drush @project-local pm-list | grep Enabled) <(drush @project-remote pm-list | grep Enabled)
@thelebster
thelebster / drupal-git-patch.sh
Created October 22, 2016 05:45 — forked from szeidler/drupal-git-patch.sh
Drupal git patch
# Normal patch.
git diff 7.x-1.x > [project_name]-[short-description]-[issue-number]-[comment-number].patch
# Interdiff patch.
git diff old_patch_branch > interdiff-[issue-number]-[old-patch-comment-number]-[comment-number].diff
@thelebster
thelebster / drush-sync-local-2-remote.sh
Created October 22, 2016 05:46 — forked from szeidler/drush-sync-local-2-remote.sh
Drush sync from local to remote
drush rsync @project-local:%files @project-remote:%files
drush rsync @project-local:%private @project-remote:%private
drush sql-sync @project-local @project-remote
@thelebster
thelebster / drush-sync-remote-2-local.sh
Created October 22, 2016 05:46 — forked from szeidler/drush-sync-remote-2-local.sh
Drush sync from remote to local
drush rsync @project-remote:%files @project-local:%files
drush rsync @project-remote:%private @project-local:%private
drush sql-sync @project-remote @project-local
@thelebster
thelebster / fix-fields.drush
Created October 22, 2016 05:49 — forked from szeidler/fix-fields.drush
Clean field_collection data, when migrating existing fields
#!/usr/bin/env drush
$result = db_query("SELECT id, data from field_config where type = 'field_collection'");
foreach ($result as $field) {
$data = unserialize($field->data);
$data['indexes'] = array('revision_id' => array('revision_id'));
$data = serialize($data);
db_query("update field_config set data = :data where id = :id", array(':data' => $data, ':id'=> $field->id));
}
@thelebster
thelebster / EmailCommand.php
Created May 6, 2017 10:22 — forked from james2doyle/EmailCommand.php
A command to test that email has been setup correctly in Laravel
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Mail;
class EmailCommand extends Command
{
@thelebster
thelebster / get-script-promise.js
Created May 6, 2017 10:22 — forked from james2doyle/get-script-promise.js
Async load a script in the page and run it. Uses promises
// this function will work cross-browser for loading scripts asynchronously
function loadScript(src) {
return new Promise(function(resolve, reject) {
const s = document.createElement('script');
let r = false;
s.type = 'text/javascript';
s.src = src;
s.async = true;
s.onerror = function(err) {
reject(err, s);
@thelebster
thelebster / nginx-options-request.conf
Created May 6, 2017 10:22 — forked from james2doyle/nginx-options-request.conf
A Nginx conf for handling OPTIONS request for functions like window.fetch
server {
# ...
# handle OPTIONS requests from window.fetch
if ($request_method = OPTIONS ) {
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "GET, OPTIONS";
add_header Access-Control-Allow-Headers "Authorization,content-type";
add_header Access-Control-Allow-Credentials "true";
@thelebster
thelebster / uniqid.php
Created May 6, 2017 10:23 — forked from james2doyle/uniqid.php
PHP uniqid function written in pure PHP
<?php
/*
* Use this if you need to recreate `uniqid` in another language
* From: http://php.net/manual/en/function.uniqid.php#95001
*/
// time in microseconds as float
$m = microtime(true);
@thelebster
thelebster / Dockerfile
Created May 6, 2017 10:23 — forked from james2doyle/Dockerfile
Example Dockerfile for a Go (golang) project. Uses the official Debian image with the latest version of Go
# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang
# Copy the local package files to the container's workspace
ADD . /go/src/github.com/username/program
# bake in some environment variables?
# ENV SOME_ENV ""