Skip to content

Instantly share code, notes, and snippets.

@dallasread
dallasread / github-review-improvements.user.js
Last active February 3, 2023 20:42
GitHub review improvements
// ==UserScript==
// @name GitHubReviewSpecMover
// @version 7
// @grant none
// @match https://github.com/*
// ==/UserScript==
((attr) => {
const backoff = (func, startingDelay = 500, factor = 1.3) => {
func()
@dallasread
dallasread / keyword-finder.user.js
Last active December 1, 2022 13:01
Find a keyword on a page
// ==UserScript==
// @name KeywordFinder
// @version 1
// @grant none
// @match https://news.ycombinator.com/*
// ==/UserScript==
(function(keyword) {
const counter = document.createElement('p')
counter.style.position = 'fixed'
@dallasread
dallasread / github-commenter.user.js
Last active December 1, 2022 13:04
github-commenter.user.js
// ==UserScript==
// @name GitHubCommenter
// @version 1
// @grant none
// @match https://dnsimple.com/admin*
// ==/UserScript==
class Commenter {
constructor($target, namespace, repo) {
this.repo = repo
@dallasread
dallasread / fullscreen-textarea.user.js
Last active November 6, 2023 13:55
Fullscreen Textarea
// ==UserScript==
// @name Big-Enough Text Area
// @version 4
// @grant none
// @match https://github.com/*
// ==/UserScript==
(function () {
document.body.innerHTML += `
<style>
@dallasread
dallasread / CustomElement.js
Created January 7, 2017 18:02
CustomElement.js
var Generate = require('generate-js'),
events = require('events'),
Bars = require('bars'),
bars = new Bars();
function removeEmptyObjects(data) {
for (var key in data) {
if (data[key]) {
if (typeof data[key] === 'object') {
if (data[key] instanceof Array) {
@dallasread
dallasread / PDF Finder
Created September 22, 2016 15:31
Find all files of a certain type from Messages
require 'shellwords'
username = "me"
filetype = ".pdf"
target = "/Users/#{username}/Desktop/pdfs"
source = "/Users/#{username}/Library/Messages/Attachments/**/*#{filetype}"
Dir[source].each do |file|
basename = File.basename(file)
`cp #{file} #{target.shellescape}/#{basename.shellescape}`
@dallasread
dallasread / search-and-replace.php
Created February 14, 2016 23:18
WordPress Search and Replace for changing domains
#!/usr/bin/php
<?php
/**
* Search and Replace on a MySQL DB that has PHP serialized fields.
* By Dallas Read, 2015.
*/
$host = isset($argv[1]) ? $argv[1] : false;
$user = isset($argv[2]) ? $argv[2] : false;
@dallasread
dallasread / redirect.php
Last active June 23, 2020 23:43
WP Redirect Template
<?php
/*
Template Name: Redirect
*/
if ($post->post_content != "") {
$url = wp_strip_all_tags($post->post_content);
} else if (!$post->post_parent) {
$children = get_pages("child_of=".$post->ID."&sort_column=menu_order");
$url = get_permalink($children[0]->ID);
@dallasread
dallasread / Gulpfile.js
Last active October 19, 2015 22:41
Basic Gulpfile.js
var browserify = require('browserify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
uglify = require('gulp-uglify'),
gulp = require('gulp'),
sass = require('gulp-sass'),
minifyCSS = require('gulp-minify-css'),
gulpif = require('gulp-if'),
rename = require('gulp-rename'),
stringify = require('stringify'),
@dallasread
dallasread / gist:92e94b7d59f1c5b45bf7
Created November 12, 2014 19:36
If not admin, hide admin bar and WP Admin area
public static function remove_admin_bar() {
if (!current_user_can("administrator")) {
show_admin_bar(false);
}
}
public static function redirect_if_not_admin() {
if (!current_user_can("administrator")) {
wp_redirect( site_url() );
exit;