Skip to content

Instantly share code, notes, and snippets.

View randell's full-sized avatar

Randell Benavidez randell

View GitHub Profile
@randell
randell / dlens-to-dragonshield.sql
Created February 5, 2024 03:29
Delver Lens SQL export to Dragon Shield-compatible CSV
SELECT
l.name AS "Folder Name",
c.quantity AS "Quantity",
0 AS "Trade Quantity",
dn.name AS "Card Name",
UPPER(de.tl_abb) AS "Set Code",
de.name AS "Set Name",
dc."number" AS "Card Number",
'NearMint' AS "Condition",
CASE dc.foil
@randell
randell / gist:6ead2d388c12abc615b36964bfd5bd72
Created February 5, 2020 21:54
Drupal branch-switching database
// Enable branch-switching the database.
if (file_exists('../.git/HEAD')) {
$head_file = file('../.git/HEAD', FILE_USE_INCLUDE_PATH);
$head_line = $head_file[0];
$head_bits = explode("/", $head_line, 3);
$branch_name = trim($head_bits[2]);
if ($branch_name !== 'master') {
$branch_name = str_replace('/', '__', $branch_name);
$branch_name = str_replace('-', '_', $branch_name);
@randell
randell / fragment-of-page-html.html.twig
Created July 5, 2018 23:55 — forked from RainbowArray/fragment-of-page-html.html.twig
Need to include a node field image in the page.html.twig template with Drupal 8? This is the most straightforward way I've found to do so. (This is using the file entity module.)
{% if node.field_hero_image.entity %}
<img src="{{ file_url(node.field_hero_image.entity.uri.value) }}"
alt="{{ node.field_hero_image.alt }}"
{% if node.field_hero_image.title %}
title="{{ node.field_hero_image.title }}"
{% endif %}
/>
{% endif %}
@randell
randell / GitHub-Forking.md
Created July 27, 2016 06:09 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, when I started going through the process of forking and issuing pull requests, I had some trouble figuring out the proper method for doing so and made quite a few mistakes along the way. I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your

@randell
randell / txt
Created June 22, 2016 12:53
Eclipse search ignored files
!*.dat, !*.f4v, !*.gif, !*.jpg, !*.m4a, !*.mp3, !*.pdf, !*.png, !*.tif, !*.zip, !*.tiff
@randell
randell / ignore_ide_settings.sh
Last active November 6, 2015 00:06
Ignoring IDE settings on Git when they've already been committed. The --cached option allows them to stay in the working tree, while being recorded for deletion. Once deleted, they will be ignored. Source: http://goo.gl/tMt7tz
git rm --cached .project
git rm --cached .classpath
git rm --cached -r .settings
# Note: ~/.ssh/environment should not be used, as it
# already has a different purpose in SSH.
env=~/.ssh/agent.env
# Note: Don't bother checking SSH_AGENT_PID. It's not used
# by SSH itself, and it might even be incorrect
# (for example, when using agent-forwarding over SSH).
agent_is_running() {
@randell
randell / apache_auth_satisfy
Created June 8, 2015 12:12
Apache Basic Httpd Auth with whitelist using Satisfy directive
AuthType Basic
AuthName "Please Log In"
AuthUserFile /some/path/.htpasswd
Require valid-user
Order deny,allow
Deny from all
Allow from 127.0.0.1
Satisfy any
@randell
randell / include_string.php
Created May 27, 2015 05:11
Output content of PHP file as string
<?php
// Source http://goo.gl/608FiA
function include_string($file){
ob_start();
include $file;
return ob_get_clean();
}
$content = return_output('some/file.php');
@randell
randell / dl-file.php
Last active August 29, 2015 14:21 — forked from hakre/dl-file.php
<?php
/*
* dl-file.php
*
* Protect uploaded files with login.
*
* @link http://wordpress.stackexchange.com/questions/37144/protect-wordpress-uploads-if-user-is-not-logged-in
*
* @author hakre <http://hakre.wordpress.com/>
* @license GPL-3.0+