Skip to content

Instantly share code, notes, and snippets.

View leonardreidy's full-sized avatar

Leonard M Reidy leonardreidy

View GitHub Profile
@leonardreidy
leonardreidy / classIIFEinsideModuleIIFE_inJSDoc3.js
Created October 8, 2016 20:27
How to use JSDoc 3 to document a class (as IIFE) inside a module (as IIFE)
/**
* The JSDoc module tag identifies the file as a module. JSDoc
* assumes all symbols in the file belong to the module, unless
* otherwise specified.
*
* @module DummyModule
*/
var DummyModule = (function() {
// The constructs tag and the memberof tag on the constructor function
@leonardreidy
leonardreidy / rotateImages.py
Created September 19, 2016 11:53
Simple function to rotate all images in the current directory with Python Pillow
# pip install Pillow if you don't already have it
# import image utilities
from PIL import Image
# import os utilities
import os
# define a function that rotates images in the current directory
# given the rotation in degrees as a parameter
if (requestCode == 5 && resultCode == RESULT_OK) {
Toast.makeText(this,"here",Toast.LENGTH_SHORT).show();
if (data != null) {
Place place = PlacePicker.getPlace(data, this);
if (place != null) {
lat = place.getLatLng().latitude;
lng = place.getLatLng().longitude;
MarkerOptions marker = new MarkerOptions().position(
place.getLatLng()).title("Hello Maps"); marker.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_RED));
gtk-color-scheme = "base_color:#ffffff\nfg_color:#4c4c4c\ntooltip_fg_color:#000000\nselected_bg_color:#f07746\nselected_fg_color:#000000\ntext_color:#3C3C3C\nbg_color:#E6E6FA\ntooltip_bg_color:#C0C0C0\nlink_color:#DD4814"
@leonardreidy
leonardreidy / FileUtilities.java
Created September 21, 2015 13:52
Java class with methods for simplifying file i/o.
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.FileSystems;
import java.io.File;
import java.io.BufferedReader;
import java.io.IOException;
import java.lang.StringBuffer;
public class FileUtilities
{
@leonardreidy
leonardreidy / StringUtilities.java
Last active October 8, 2016 20:31
Simple Java class containing methods for performing common actions on Strings.
public class StringUtilities
{
/**
* Check if input string is a vowel
* Author: http://stackoverflow.com/users/1357341/arshajii
**/
public static boolean isVowel(String inStr)
{
return "aeiou".indexOf(inStr.toLowerCase()) >= 0;
@leonardreidy
leonardreidy / taboutofbraces.txt
Last active October 8, 2016 20:31
Tab out of Braces - Sublime Text
<snippet>
<content><![CDATA[
($1)
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>(</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
@leonardreidy
leonardreidy / Extract-Salary-Calculator-Metrocodes-from-HTML.py
Last active October 8, 2016 20:32
The goal of this code is to extract data from a web page and output it to an Excel file. The specific data is a collection of metro area names and codes used in an online salary calculator. Using Splinter, I automate the browser giving a short script a list of metro codes of interest. To get the metro codes I need to extract option values and te…
# BeautifulSoup is used to extract data from a html source file
from bs4 import BeautifulSoup
# tablib is used to output the data to an Excel file with a minimum of hassle
import tablib
# open the file of interest, a file containing the html source for
# the select/options tags you want to extract data from
# INFILE is a placeholder for a filename
infile = open(INFILE, 'r')
@leonardreidy
leonardreidy / ipeds-simple-crawler.py
Created June 4, 2014 20:45
A short python script which takes a list of IPEDS IDs, opens a browser, navigates to the Data Center and looks up each institution in the list individually, then downloads the page IPEDS presents, after expanding all collapsed content on the page. This script does not download the image files or other resources like that. It's just text and tabl…
import time
from splinter import Browser
browser = Browser()
inst_list = [IPEDSID-1, IPEDSID-2, IPEDSID-3, IPEDSID-n]
browser.visit("http://nces.ed.gov/ipeds/datacenter/")
browser.execute_script('javascript:doSubmit(6)')
button = browser.find_by_id('ibtnLoginLevelOne')
button.click()
@leonardreidy
leonardreidy / extract-x.py
Created June 3, 2014 13:26
How to extract or remove elements from BeautifulSoup soup
# extract (remove) some element from the soup
[s.extract() for s in soup(x)]
# examples
# extract style elements
[s.extract() for s in soup('style')]
# extract script elements