Skip to content

Instantly share code, notes, and snippets.

View jdmar3's full-sized avatar

John D. Martin III jdmar3

View GitHub Profile
@darrenpmeyer
darrenpmeyer / darkproxies.pac
Last active May 28, 2021 06:16
PAC file for I2P, Tor, etc. proxy configs
function FindProxyForURL(url, host) {
if (dnsDomainIs(host, ".i2p")) { return "HTTP localhost:4444"; }
if (dnsDomainIs(host, ".onion")) { return "SOCKS localhost:9050"; }
return "DIRECT";
}
@yershalom
yershalom / get_commit_count.py
Created December 17, 2017 13:19
Easy way to calculate commits count from the github api
import requests
base_url = 'https://api.github.com'
def get_all_commits_count(owner, repo, sha):
first_commit = get_first_commit(owner, repo)
compare_url = '{}/repos/{}/{}/compare/{}...{}'.format(base_url, owner, repo, first_commit, sha)
commit_req = requests.get(compare_url)
@woodrow
woodrow / onc_converter.py
Created April 27, 2016 23:54
Convert OpenVPN config files to ChromeOS ONC files
import argparse
import json
import re
import sys
import uuid
class OpenVPNNetworkConfiguration(object):
KNOWN_CONFIG_KEYS = {
'name': {'key': 'Name'},
@andrewheiss
andrewheiss / yoda_pie.R
Last active September 21, 2015 13:48
Yoda pie chart
library(dplyr)
library(ggplot2)
df <- data_frame(value = c(5, 5, 0),
variable = factor(c("Do ", "Do not ", "Try"),
ordered=TRUE))
yoda.plot <- ggplot(df, aes(x = "", y = value, fill = variable)) +
geom_bar(width = 1, stat = "identity") +
scale_fill_manual(values = c("#7AA42F", "#B3B575", "#5978E1"), name=NULL,
library(ggplot2)
library(Cairo) # MAGIC PACKAGE
fake.data <- data.frame(x = rnorm(100), y = rnorm(100), z = rbinom(100, 1, 0.5))
p <- ggplot(fake.data, aes(x=x, y=y)) +
geom_line() +
labs(x="Science", y="More science", title="Here's a title") +
facet_wrap(~ z) +
theme_bw() +
#!/usr/bin/python
# Title: Reddit Data Mining Script
# Authors: Clay McLeod
# Description: This script mines JSON data
# from the Reddit front page and stores it
# as a CSV file for analysis.
# Section: Python
# Subsection: Data Science
want=["domain", "subreddit", "subreddit_id" "id", "author", "score", "over_18", "downs", "created_utc", "ups", "num_comments"]
@nerdsrescueme
nerdsrescueme / regex.txt
Created September 23, 2011 16:08
Common Regex
Perl and PHP Regular Expressions
PHP regexes are based on the PCRE (Perl-Compatible Regular Expressions), so any regexp that works for one should be compatible with the other or any other language that makes use of the PCRE format. Here are some commonly needed regular expressions for both PHP and Perl. Each regex will be in string format and will include delimiters.
All Major Credit Cards
This regular expression will validate all major credit cards: American Express (Amex), Discover, Mastercard, and Visa.
//All major credit cards regex
'/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|622((12[6-9]|1[3-9][0-9])|([2-8][0-9][0-9])|(9(([0-1][0-9])|(2[0-5]))))[0-9]{10}|64[4-9][0-9]{13}|65[0-9]{14}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})*$/'