Skip to content

Instantly share code, notes, and snippets.

@broskees
broskees / anonymous-singleton.php
Last active July 20, 2023 16:09
PHP — Anonymous Singleton Class
<?php
$singleton = get_class(
new class
{
protected static $instance;
public static function getInstance()
{
if (! isset(self::$instance)) {
@Luna-Klatzer
Luna-Klatzer / __init__.py
Last active February 18, 2024 14:33
Anki Plugin for auto-filling data in Anki cards using the Jisho.org API
# Jisho.org Support for Anki
import os, re, json, requests, urllib.request, urllib.parse
from aqt import gui_hooks
from aqt import mw
from aqt.qt import qconnect
from aqt.editor import Editor
from aqt.utils import showInfo
from anki.utils import stripHTML
@broskees
broskees / becoming-a-webdev.md
Last active June 26, 2021 02:58
Becoming A Web Developer: A - Z
@davidwebca
davidwebca / override-wp-core-blocks-sage-10.php
Last active March 6, 2023 20:40
Add blade / override core block views in Sage 10.
<?php
/**
* Add this to your filters.php file in a Sage 10 theme.
* It will look at "resources/views/core/{blockname}.blade.php
* and render the view with "block_content" and "block" as variables.
*
* You can also use View Composers built in Sage 10 to pass more
* data to the block as you wish. For ACF blocks, I recommend
* generoi/sage-acfblocks which is definitely the cleanest
* method to include ACF blocks in Sage 10 I found so far.
@jonashackt
jonashackt / downgrade_brew_package.sh
Created September 24, 2018 12:07
Downgrade homebrew (cask) package
# Uninstall current version you want to downgrade
brew cask uninstall <PackageName>
# Edit Cask file
brew cask edit <PackageName>
# e.g. Vagrant
brew cask edit vagrant
```
cask 'vagrant' do
@ghassani
ghassani / QueryBuilder.php
Created September 19, 2018 18:28
Simple PHP SQL Query Builder for PDO
<?php
class QueryBuilder {
const QUERY_SELECT = 1;
const QUERY_INSERT = 2;
const QUERY_UPDATE = 3;
const QUERY_DELETE = 4;
const QUERY_REPLACE = 5;
const PARAMETER_STRING = 1;
@RiFi2k
RiFi2k / nginx.conf.j2
Last active April 7, 2021 22:50
Trellis nginx.conf file to include setting the real IP from Cloudflare if you use their DNS and SSL certs - https://github.com/roots/trellis/blob/master/roles/nginx/templates/nginx.conf.j2
# {{ ansible_managed }}
# nginx Configuration File
# http://wiki.nginx.org/Configuration
# Run as a less privileged user for security reasons.
user {{ nginx_user }};
# How many worker threads to run;
# "auto" sets it to the number of CPU cores available in the system, and
@thierrypigot
thierrypigot / acf-missing.php
Created June 3, 2016 10:13
WordPress mu plugins to check if "Advanced Custom Fields Pro" is active.
<?php
if( !class_exists('acf') )
{
$tp_acf_notice_msg = __( 'This website needs "Advanced Custom Fields Pro" to run. Please download and activate it', 'tp-notice-acf' );
/*
* Admin notice
*/
add_action( 'admin_notices', 'tp_notice_missing_acf' );
function tp_notice_missing_acf()
@yaodong
yaodong / gist:f5b785c5b17337ce1b9a
Created February 11, 2016 23:15
things cloud requests
login
curl -H "Host: cloud.culturedcode.com" -H "Content-Type: application/json; charset=UTF-8" -H "Proxy-Connection: keep-alive" -H "Accept: */*" -H "User-Agent: ThingsMac/20803501mas (x86_64; OS X 10.11.3; en_US)" -H "Authorization: Password pppppwwwwdddd" -H "Accept-Language: en-us" --compressed https://cloud.culturedcode.com/version/1/account/user%40exmaple.com
get key
curl -H "Host: cloud.culturedcode.com" -H "Content-Type: application/json; charset=UTF-8" -H "Proxy-Connection: keep-alive" -H "Accept: */*" -H "User-Agent: ThingsMac/20803501mas (x86_64; OS X 10.11.3; en_US)" -H "Authorization: Password pppppwwwwdddd" -H "Accept-Language: en-us" --compressed https://cloud.culturedcode.com/version/1/account/user%40exmaple.com/own-history-keys
get index
curl -H "Host: cloud.culturedcode.com" -H "Content-Type: application/json; charset=UTF-8" -H "Proxy-Connection: keep-alive" -H "Accept: */*" -H "User-Agent: ThingsMac/20803501mas (x86_64; OS X 10.11.3; en_US)" -H "Accept-Language: en-us" --compressed https: