Skip to content

Instantly share code, notes, and snippets.

import praw # simple interface to the reddit API, also handles rate limiting of requests
import re
from collections import deque
from time import sleep
USERNAME = "Your username here"
PASSWORD = "Your password here"
USERAGENT = "Your useragent string here. It should include your /u/username as a courtesy to reddit"
r = praw.Reddit(USERAGENT)
@johnpc
johnpc / tmux.conf
Created June 8, 2014 16:37
This is a much more intuitive tmux.conf. Just rename it '.tmux.conf' and put it in your ~/
###############################
# _ #
# | |_ _ __ ___ _ ___ __ #
# | __| '_ ` _ \| | | \ \/ / #
# | |_| | | | | | |_| |> < #
# \__|_| |_| |_|\__,_/_/\_\ #
# #
###############################
############################################################################
@johnpc
johnpc / email based on google spreadsheet
Last active August 29, 2015 14:03
download google spreadsheet spreadsheet as csv and read through it, emailing someone when the record includes todays date
require 'mail'
require 'date'
require 'gdata/client'
require 'gdata/http'
require 'gdata/auth'
options = { :address => "smtp.gmail.com",
:port => 587,
:domain => 'your.host.name',
:user_name => '<username>',
@johnpc
johnpc / gist:c7d9c7731a556cd60f5f
Last active August 29, 2015 14:05
Working ordrin guest order request
require "ordrin"
my_secret_key = "PUT SECRET KEY HERE"
ordrin_api = Ordrin::APIs.new(my_secret_key, :test)
args = Hash.new
args["rid"] = '29900'
args["em"] = "john@johncorser.com"
args["tray"] = '25243987/1'
args["tip"] = "0.00"
args["first_name"] = "John"
args["last_name"] = "Corser"
@johnpc
johnpc / Android Bluetooth Cordova
Created September 30, 2014 20:24
A cordova plugin that checks whether an android device has bluetooth activated
package org.apache.cordova.plugin;
import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothAdapter;
@johnpc
johnpc / Android GPS Cordova Plugin
Created October 1, 2014 15:10
This class determines whether android device has an location services (GPS) enabled, called from JavaScript using Cordova.
package org.apache.cordova.plugin;
import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.location.LocationManager;
@johnpc
johnpc / keybase.md
Created February 2, 2019 16:08
Keybase Proof

Keybase proof

I hereby claim:

  • I am johnpc on github.
  • I am johncorser (https://keybase.io/johncorser) on keybase.
  • I have a public key ASCgRRcmi9jc4HSfYHspPxNENCMnbgdSE6ZczSYuLIRWlwo

To claim this, I am signing this object:

@johnpc
johnpc / is_it_up.go
Created March 20, 2019 04:26
Very simple Go program to monitor uptime
package main
import (
"fmt"
"net/http"
"time"
)
func main() {
links := []string{
@johnpc
johnpc / antd-cascader-bug.js
Last active June 20, 2019 20:04
Antd Cascader bug
// Reproduce with the following steps:
// 1. npx create-react-app antd-bug
// 2. cd antd-bug
// 3. npm install antd && yarn add antd
// 4. copy this code into into src/index.js
// 5. npm start
// Navigate to localhost:3000
// Use the search box to search for "option". Use backspace and re-type. You will see lines get duplicated.
// Screen capture video available here: https://www.youtube.com/watch?v=bc9fT4T87ek
// Gif version available here: https://jpc.io/r/antd-bug.gif
@johnpc
johnpc / import_safari_passwords_from_csv.applescript
Last active November 9, 2019 17:18
Import safari passwords from csv
tell application "Safari"
activate
end tell
tell application "System Events" to tell application process "Safari"
set frontmost to true
keystroke "," using {command down}
set tb to toolbar 1 of window 1
set buttonName to (name of button 4 of tb as string)
click button 4 of tb
set theResult to display dialog "Please unlock " & buttonName & " and press Continue when unlocked" buttons {"Cancel", "Continue"} default button "Continue"