Skip to content

Instantly share code, notes, and snippets.

View rugbyprof's full-sized avatar

Terry Griffin rugbyprof

View GitHub Profile
@rugbyprof
rugbyprof / cpp_string_to_binary_file
Last active February 14, 2020 02:08
zeros and ones to a file (huffman helper)
#include <iostream>
#include <fstream>
#include <vector>
// Write a binary "string" to a file as binary. Used in conjunction with a previous Huffman encoding project.
using namespace std;
int main(){
@rugbyprof
rugbyprof / Linux_concat_avi_files
Last active August 29, 2015 13:56
Concatenate two avi files
cat Part1.avi Part2.avi > tmp.avi && mencoder -forceidx -oac copy -ovc copy tmp.avi -o output.avi && rm -f tmp.avi
//Obviously it requires mencoder, which comes with mplayer
@rugbyprof
rugbyprof / Osx_add_spacer_on_dock.sh
Last active February 14, 2020 02:09
Add a spacer on your mac dock.
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
@rugbyprof
rugbyprof / Osx_show_hidden_files
Last active August 29, 2015 13:57
Show files in Osx terminal / finder.
# If it doesn't work, you may want to try switching YES/NO to TRUE/FALSE
# It is case sensitive!
defaults write com.apple.Finder AppleShowAllFiles NO
defaults write com.apple.Finder AppleShowAllFiles TRUE
@rugbyprof
rugbyprof / great_circle.sql
Last active February 6, 2021 23:57
Mysql Great Circle Distance
# Here's the SQL statement that will find the closest 20 locations that are within a radius of 25 miles
# to the 37, -122 coordinate. It #calculates the distance based on the latitude/longitude of that row
# and the target latitude/longitude, and then asks for only rows #where the distance value is less than
# 25, orders the whole query by distance, and limits it to 20 results. To search by kilometers #instead
# of miles, replace 3959 with 6371.
SELECT id, ( 3959 * acos( cos( radians(37) ) *
cos( radians( lat ) ) *
cos( radians( lng ) - radians(-122) ) +
sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance
@rugbyprof
rugbyprof / shape2mysql
Created June 16, 2014 22:16
Add shapefile to MySQL
ogr2ogr -f MySQL MySQL:DATABASENAME,host=localhost,user=USER,password=PASSWORD SHAPEFILE.shp -nln TABLENAME -update -overwrite -lco engine=MYISAM
@rugbyprof
rugbyprof / us_states.php
Created July 2, 2014 04:36
Php array of u.s. states
$states = array(
'Alabama',
'Alaska',
'Arizona',
'Arkansas',
'California',
'Colorado',
'Connecticut',
'Delaware',
'District-of-Columbia',
@rugbyprof
rugbyprof / Example.html
Last active August 29, 2015 14:03
Rudimentary example using bootstrap and jquery.
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Contact Card</title>
<!-- Include our personal style sheet -->
<link rel="stylesheet" type="text/css" href="style.css">
<!-- Include Bootstrap's style sheet -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
@rugbyprof
rugbyprof / geo.js
Last active August 29, 2015 14:04
geo.js
//Source:
//https://code.google.com/p/geo-location-javascript/
var start_stop_btn, wpid = false,
map, z, op, prev_lat, prev_long, min_speed = 0,
max_speed = 0,
min_altitude = 0,
max_altitude = 0,
distance_travelled = 0,
min_accuracy = 150,
date_pos_updated = "",
@rugbyprof
rugbyprof / simple_backend.php
Last active February 14, 2020 02:05
over simple php backend
<?php
$_POST['action'] = 'select';
// $_POST['First'] = 'Mark';
// $_POST['Last'] = 'Twain';
// $_POST['Thumb'] = '';
// $_POST['Lat'] = '33.12343';
// $_POST['Lon'] = '-98.234563';
// $_POST['Sex'] = 'M';
// $_POST['Phone'] = '9403687777';