Skip to content

Instantly share code, notes, and snippets.

View rinogo's full-sized avatar

Rich Christiansen rinogo

  • Social5
  • Utah, USA
View GitHub Profile
@rinogo
rinogo / 0_reuse_code.js
Created October 1, 2015 16:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@rinogo
rinogo / back-button-override-service.ts
Created December 21, 2016 00:49
Ionic 1 (Angular 1.x) back button override - Typescript version
//Adapted from http://stackoverflow.com/a/36733061/114558
export class BackButtonOverrideService {
static $inject = ["$rootScope", "$ionicPlatform"];
constructor(private $rootScope: ng.IRootScopeService, private $ionicPlatform: ionic.platform.IonicPlatformService) {
}
setup($scope: ng.IScope, customBackFunction: Function) {
var that = this;
@rinogo
rinogo / nightmare-catch-example.js
Created April 13, 2017 21:42
An example of how to use the `.catch()` mechanism in NightmareJS
var Nightmare = require("nightmare");
var nightmare = new Nightmare();
nightmare
.goto("https://non-existent-website-nifgeoawniogea.com")
.catch(handleError);
//Note: You can manually raise an exception from within a `.then()` command with a normal `throw new Error()`:
//throw new Error("Description of the error.");
@rinogo
rinogo / tiny_mce.js
Created May 10, 2017 22:32
Fix for Wordpress 3.7's Tiny MCE Chrome 58 bug
(function(e){var a=/^\s*|\s*$/g,b,d="B".replace(/A(.)|B/,"$1")==="$1";var c={majorVersion:"3",minorVersion:"5.9",releaseDate:"2013-10-18",_init:function(){var s=this,q=document,o=navigator,g=o.userAgent,m,f,l,k,j,r;s.isIE11=g.indexOf("Trident/")!=-1&&(g.indexOf("rv:")!=-1||o.appName.indexOf("Netscape")!=-1);s.isOpera=e.opera&&opera.buildNumber;s.isWebKit=/WebKit/.test(g);s.isIE=!s.isWebKit&&!s.isOpera&&(/MSIE/gi).test(g)&&(/Explorer/gi).test(o.appName)||s.isIE11;s.isIE6=s.isIE&&/MSIE [56]/.test(g);s.isIE7=s.isIE&&/MSIE [7]/.test(g);s.isIE8=s.isIE&&/MSIE [8]/.test(g);s.isIE9=s.isIE&&/MSIE [9]/.test(g);s.isGecko=!s.isWebKit&&!s.isIE11&&/Gecko/.test(g);s.isMac=g.indexOf("Mac")!=-1;s.isAir=/adobeair/i.test(g);s.isIDevice=/(iPad|iPhone)/.test(g);s.isIOS5=s.isIDevice&&g.match(/AppleWebKit\/(\d*)/)[1]>=534;if(e.tinyMCEPreInit){s.suffix=tinyMCEPreInit.suffix;s.baseURL=tinyMCEPreInit.base;s.query=tinyMCEPreInit.query;return}s.suffix="";f=q.getElementsByTagName("base");for(m=0;m<f.length;m++){r=f[m].href;if(r){if(/^htt
@rinogo
rinogo / ring-bill.sh
Created October 5, 2017 15:45
Ring the bell in terminal/bash
#!/bin/sh
tput bel
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 1 column, instead of 2 in line 3.
#Original Source: http://answers.google.com/answers/threadview/id/107201.html
#
#This data is all available in raw form from the United States Census
#Site, which is about as authoritative a source as you will get on the
#subject. I have used the following files:
#
#US Male Names: http://www.census.gov/genealogy/names/dist.male.first
#US Female Names: http://www.census.gov/genealogy/names/dist.female.first
#US Last Names: http://www.census.gov/genealogy/names/dist.all.last
#
//Source data from http://answers.google.com/answers/threadview/id/107201.html
var male = ["abdul","abe","abel","abraham","abram","adalberto","adan","adolfo","adolph","agustin","ahmad","ahmed","al","alan","alberto","alden","aldo","alec","alejandro","alfonso","alfonzo","alfred","alfredo","allan","alonso","alonzo","alphonse","alphonso","alton","alvaro","alvin","amado","ambrose","amos","anderson","andreas","andres","andy","anibal","antione","antoine","anton","antone","antony","antwan","archie","arden","arlen","arlie","armand","armando","arnold","arnoldo","arnulfo","aron","arron","art","arturo","asa","august","augustus","aurelio","barney","barrett","barry","bart","barton","basil","beau","ben","benedict","benito","benjamin","bennett","benny","benton","bernard","bernardo","bert","bertram","bill","blaine","bo","bob","booker","boris","boyce","boyd","brad","bradford","bradley","bradly","brady","brain","branden","brant","brendan","brendon","brent","brenton","bret","brice","brock","broderick","brooks","bruce","bruno","b
@rinogo
rinogo / script.js
Last active April 10, 2018 22:09
Improved script.js for Contact Form 7 reCAPTCHA Wordpress plugin. It shows an error message if the user fails to check the reCAPTCHA ("I am not a robot") box.
function contact_form_7_recaptcha_callback() {
jQuery(function($){
$('.g-recaptcha-explicit-id').each(function(){
$(this).data('grecaptcha_id', grecaptcha.render($('#' + this.value)[0], {
'sitekey' : contact_form_7_recaptcha_data.sitekey
}));
});
});
};
@rinogo
rinogo / UsHolidays.php
Created November 26, 2018 16:45
Simple unit-tested class to calculate federal holiday dates for the United States. Methods are included for determining if a date (timestamp) is considered a date and for accessing holidays by name and by timestamp.
<?php
//Adapted by rich at byu.net from https://www.damia.no/calculating-u-s-federal-holidays-with-php/
class UsHolidays {
private $year;
private $list;
const ONE_DAY = 86400; //Number of seconds in one day
@rinogo
rinogo / plugin.php
Created January 3, 2019 20:53
YOURLS plugin: keep query string
<?php
/*
Plugin Name: Keep Query String
Description: Adds short URL query string, if any, to the long URL
Version: 0.1
Author: Ozh
*/
yourls_add_filter('redirect_location', 'ozh_kqs');