Skip to content

Instantly share code, notes, and snippets.

View devidw's full-sized avatar
🌌
realizing reality

David Wolf devidw

🌌
realizing reality
View GitHub Profile
@kantoniak
kantoniak / FigureExtParsedown.class.php
Last active November 26, 2021 09:22
Parsedown extension to wrap single-image lines in <figure>, not <p>. Public domain. See https://github.com/erusev/parsedown/issues/180#issuecomment-451486639
<?php
class FigureExtParsedown extends Parsedown {
// Matches Markdown image definition
private $MarkdownImageRegex = "~^!\[.*?\]\(.*?\)$~";
public function __construct () {
// Add blockFigure to non-exclusive handlers for text starting with !
$this->BlockTypes['!'][] = 'Figure';
@JungeAlexander
JungeAlexander / import-package-from parent.py
Created November 27, 2014 17:22
Import modules from parent folder in Python
# From http://stackoverflow.com/a/11158224
# Solution A - If the script importing the module is in a package
from .. import mymodule
# Solution B - If the script importing the module is not in a package
import os,sys,inspect
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)
@gaoyifan
gaoyifan / google-fonts-proxy
Last active November 10, 2022 10:02
google-fonts-proxy
server {
listen 80;
listen 443;
listen [::]:80;
listen [::]:443;
server_name fonts.lug.ustc.edu.cn;
access_log /var/log/nginx/revproxy_access.log;
error_log /var/log/nginx/revproxy_error.log;
@itsliamjones
itsliamjones / array-value-recursive.php
Created May 26, 2016 13:54
Get all values from specific key in a multidimensional array, similar to array_columns
<?php
/**
* Get all values from specific key in a multidimensional array
*
* @param string $key key(s) of value you wish to extract
* @param array $arr where you want
*
* @return null|string|array
*/
@riipandi
riipandi / optimator.php
Last active June 27, 2023 20:05
WordPress Snippets
<?php defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/*
* Plugin Name: Optimator
* Plugin URI: https://aris.web.id/
* Description: Some basic WordPress configuration optimization to make it better than default. This plugin contains other simplified plugins and snippets.
* Author: Aris Ripandi
* Author URI: https://aris.web.id/
* Version: 1.0
* License: GPLv3
* Text Domain: optimator
@blixt
blixt / OculusQuest.md
Last active February 12, 2024 14:06
Streaming Oculus Quest wirelessly over WiFi to macOS (on a MacBook)

Streaming an Android-based VR headset to your computer

Setting it up the first time

The first time you have to set it up with a cable. The Oculus Quest has a USB-C port (the one used for charging). Use this to connect to your computer.

Preparing your Oculus Quest

Your Quest needs to be in Developer mode. This is super easy, just open your companion app on your phone and go to Settings and enable Developer

@jamesluberda
jamesluberda / graphql-for-gists.md
Created June 20, 2018 01:07
Simple User Gists Query Using GitHub GraphQL API (v4 API)

I couldn't find any examples of gists queries using GraphQL--most GraphQL examples seem to focus on traditional repositories--so here is one. As a preface, I cannot recommend strongly enough, at least when getting started, developing queries using the GitHub GraphQL Explorer. I initially started by issuing queries via curl, constructing them using the docs available on the site and a downloaded copy of the schema. Unfortunately, I ended up with errors that I couldn't quite parse. I knew, for example, from the schema, the possible field values for ordering gists. However, whenever I tried to use one of those values, the API returned that it was invalid, like so:

{"data":null,"errors":[{"message":"Argument 'orderBy' on Field 'gists' has an invalid value. Expected type 'GistOrder'.","locations":[{"line":1,"column":48}]}]}"

When I finally turned to the Explorer, I discovered that not only was the value I was using correct (field: CREATED_AT), thanks to its auto

@beeman
beeman / remove-all-from-docker.sh
Created November 15, 2016 03:04
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@RadGH
RadGH / woocommerce-custom-cart-item-data.php
Last active April 27, 2024 17:25
Get and set custom cart item/product information prior to WooCommerce checkout, and carry those valus over to Order Item Metadata.
<?php
// UPDATE: Stefan from Stack Overflow has explained a better way to handle cart item data.
// See http://stackoverflow.com/a/32327810/470480
// ----------------------
/*
Instructions:
@dcode
dcode / GitHub Flavored Asciidoc (GFA).adoc
Last active May 9, 2024 06:11
Demo of some useful tips for using Asciidoc on GitHub

GitHub Flavored Asciidoc (GFA)