Skip to content

Instantly share code, notes, and snippets.

View star-szr's full-sized avatar

star-szr

View GitHub Profile
@star-szr
star-szr / allpinboard.py
Last active September 5, 2019 15:30 — forked from dlo/allpinboard.py
Python version of https://gist.github.com/3773519 that pulls all bookmarks on the first sync, and does incremental updates afterwards. Updated to use Pinboard API token instead of password authentication.
#!/usr/bin/env python
"""
This script is designed to generate a simple html file with _all_ of your
Pinboard.in bookmarks The HTML file can be added to Launchbar's index as a
custom bookmark file and you can search your entire Pinboard.in collection
instantly from Launchbar (by title only). It includes any applied tags as part
of the title to aid in searching.
You should edit the `token`, `bookmark_filename`, and `local_timezone`
@star-szr
star-szr / .create-new-branch.sh
Last active March 8, 2019 11:32
Quick branch creation and patch applying
# Create or go to branch.
git go <name of branch>
# Apply the patch, commit with a commit message of "p".
cape && gcm p
@star-szr
star-szr / TweetsBlock.php
Created January 2, 2015 03:05
Example showing usage of the processed_text element in Drupal 8
<?php
namespace Drupal\twitter_pull\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides a block for executing PHP code.
*
* @Block(
* id = "twitter_pull_tweets_block",
@star-szr
star-szr / services.yml
Last active August 29, 2015 13:59
Disable cache_render or other cache bins in Drupal 8
services:
cache.backend.memory:
class: Drupal\Core\Cache\MemoryBackendFactory
@star-szr
star-szr / dispatch-postbox.scpt
Created April 3, 2014 03:02
AppleScript application to open x-dispatch:// links in Postbox on OS X
on open location messageUri
(*
Extract message ID from the message:// URI. Where [MESSAGEID] is the message ID,
the Dispatch OS X URL Helper sets up URLs for Mail.app in the following format:
message://%3c[MESSAGEID]%3e
*)
set messageId to text 14 thru -4 of messageUri
do shell script "open x-postbox-message://" & messageId
end open location
@star-szr
star-szr / mytheme.theme.php
Created March 28, 2014 19:33
Adding template suggestions for view modes and content types in Drupal 8
<?php
/**
* Implements hook_theme_suggestions_HOOK_alter() for node.html.twig.
*/
function MYTHEME_theme_suggestions_node_alter(array &$suggestions, array $variables) {
// Add template suggestions based on the current view mode.
$node = $variables['elements']['#node'];
$suggestions[] = 'node__' . $variables['elements']['#view_mode'];
$suggestions[] = 'node__' . $node->bundle() . '__' . $variables['elements']['#view_mode'];
}
@star-szr
star-szr / d8-patches.sh
Last active December 23, 2015 09:09
Bash aliases for testing and applying patches based on the URL on your clipboard. If you're on OS X, grab the first three lines and add to your ~/.bash_profile. If you're on Linux, grab lines 5-8 and add to your ~/.bash_profile or ~/.bashrc or whatnot :)Testbot uses git to apply patches, I only include the `patch` version here because sometimes …
# These ones are for OS X.
alias cav='curl `pbpaste` | git apply -v --check'
alias capv='curl `pbpaste` | patch -p1 --dry-run'
# These are untested but should work on many flavours of Linux. If they don't,
# please leave a comment!
alias cav='curl `xsel --clipboard --output` | git apply -v --check'
alias capv='curl `xsel --clipboard --output` | patch -p1 --dry-run'
# Patch shortcuts (some duplication of the above, but covers more use cases).
@star-szr
star-szr / drupal8.sh
Created September 3, 2013 15:40
Drupal 8 bash functions
# Clean up Drupal 8 installation and do a pull.
function cleand8() {
chmod u+w sites/default
git reset --hard
git checkout 8.x
git pull
sudo rm -rf sites/default/files/php
drush cc all
}
@star-szr
star-szr / xhprof-kit.sh
Last active February 7, 2016 14:16
xhprof-kit aliases and functions
# Creates a baseline from your current branch (should usually be 8.x).
alias bbranch='./xhprof-kit/benchmark-branch.sh `git rev-parse --abbrev-ref HEAD`'
# Using the baseline xhprof identifier from the bbranch command above will benchmark 8.x against the baseline and your patched branch.
# e.g.
# bbranches [XHPROF-IDENTIFIER] [twig-branch-name-here-1234456]
function bbranches() {
originalbranch="$(git rev-parse --abbrev-ref HEAD)"
base=$1
shift
@star-szr
star-szr / Custom.css
Created September 27, 2011 17:45
IR_Black Theme (with sidebar and view-source colors) for Chrome Developer Tools
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*