Skip to content

Instantly share code, notes, and snippets.

@jpriebe
jpriebe / us_state_capitals.json
Created January 7, 2016 19:33
US State Capitals JSON file
{
"AL": {
"name": "Alabama",
"capital": "Montgomery",
"lat": "32.361538",
"long": "-86.279118"
},
"AK": {
"name": "Alaska",
"capital": "Juneau",
#!/bin/sh
####---------------------------------------------------------------------------
#### fix_swap.sh
####
#### designed for use with CentOS 7; we have noticed that our CentOS 7
#### hosts often use large amounts of swap when plenty of memory is
#### available. This causes false alarms in our system monitoring software
#### (zabbix).
####
#### this script reconfigures the system to be less swappy, and it
<?php
/**
* Authenticates to a ubiquiti EdgeOS router and enable/disable firewall rules
*
*/
class ubiquiti
{
private $_host = '';
private $_login_url = '';
private $_json_url = '';
@jpriebe
jpriebe / ffmpeg_decklink_h264_qsv.sh
Created October 26, 2016 20:19
Example script to encode video from a Decklink Mini Recorder using h264_qsv
@jpriebe
jpriebe / picasa_tags_to_exif.py
Created December 11, 2016 18:00
Move Picasa 3 tags into EXIF data for an entire library of photos
#!/usr/bin/python
from picasa3meta import pmpinfo
from picasa3meta import thumbindex
import fnmatch
import os
import sys
# python picasa_tags_to_exif.py db_dir root_dir search replace
<?php
/**
* Class for interacting with an SMB server using the system command "smbclient".
* Of course this assumes that you have the smbclient executable installed and
* in your path.
*
* It is not the most efficient way of interacting with an SMB server -- for instance,
* putting multiple files involves running the executable multiple times and
* establishing a connection for each file. However, if performance is not an
* issue, this is a quick-and-dirty way to move files to and from the SMB
@jpriebe
jpriebe / spotify-playlist-indexer.php
Created April 30, 2017 11:37
Builds an HTML index of all Spotify playlists belonging to a particular user
#!/usr/bin/php -q
<?php
/**
* Builds an HTML index of all Spotify playlists belonging to a particular user;
* unfortunately, the API does not return folder information, so you can't
* structure the index according to folders.
*
* How to use:
* 1. go to https://developer.spotify.com/, log in, and create an app; you
* will need the Client ID and Client Secret
@jpriebe
jpriebe / NestedScrollViewManager.js
Last active August 15, 2021 13:23
Appcelerator Titanium code for managing scrollviews inside of scrollviews
function NestedScrollViewManager (parent_view)
{
// Appcelerator Titanium code for managing scrollviews inside of scrollviews (not true Android
// NestedScrollViews, but just a horizontal scrollview inside of a vertical scrollview).
//
// If you want to put a horizontal scrollview inside a vertical scrollview (like the Netflix app UI),
// it seems to work reasonably well on iOS. But on android, the user experience is very janky.
// Unless the user's drag movements are nearly exactly horizontal, there will be some movement of
// the parent scrollview, and then it becomes very difficult to scroll the child view. Flinging is
// almost impossible.
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
@jpriebe
jpriebe / degrees_to_direction.php
Created May 3, 2018 12:12
Convert degrees to direction string
function degrees_to_direction ($degrees, $short=true)
{
$dir_ary = [
['N', 'North'],
['NNE', 'North Northeast'],
['NE', 'Northeast'],
['ENE', 'East Northeast'],
['E', 'East'],
['ESE', 'East Southeast'],
['SE', 'Southeast'],