Skip to content

Instantly share code, notes, and snippets.

View rms1000watt's full-sized avatar

Ryan M Smith rms1000watt

View GitHub Profile
@rms1000watt
rms1000watt / sql-lat-long-to-geography.sql
Created July 19, 2016 01:30
SQL Server Lat Long to Geography
-- http://www.sql-server-helper.com/sql-server-2008/convert-latitude-longitude-to-geography-point.aspx
UPDATE [Table1]
SET [GeoLocation] = geography::STPointFromText('POINT(' + CAST([Longitude] AS VARCHAR(20)) + ' ' + CAST([Latitude] AS VARCHAR(20)) + ')', 4326)
@rms1000watt
rms1000watt / bash-ffmpeg-speed-up-mp4.sh
Created July 21, 2016 14:55
FFMPEG from command line to speed up mp4 with installation steps
## If error installing ffmpeg = "yasm/nasm not found or too old"
## http://www.sthshare.com/wordpress/yasmnasm-not-found-or-too-old-on-linux-servercenots.html
# wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
# tar -xvf yasm-1.3.0.tar.gz
# cd yasm-1.3.0
# ./configure
# make
# make install
## http://superuser.com/questions/160443/software-to-speed-up-playback-of-mp4-files
@rms1000watt
rms1000watt / HTMLtoPDF.sh
Created July 21, 2016 18:45
Generate HTML Report then convert HTML Report to PDF
# cd to this directory
weasyprint index.html report.pdf
@rms1000watt
rms1000watt / python-generate-pdf-report.py
Created July 21, 2016 18:48
Python to generate PDF report
from fpdf import FPDF
PORTRAIT_FULL_WIDTH = 190
LANDSCAPE_FULL_WIDTH = 277
MAX_ROWS = 57
LEFT_MARGIN = 10.00125
pdf = None
def main():
global pdf
@rms1000watt
rms1000watt / python-transfer-file-ssh.py
Created July 27, 2016 20:49
Transfer file over SSH (SFTP) in Python
# Tony Meyer: http://stackoverflow.com/questions/68335/how-do-i-copy-a-file-to-a-remote-server-in-python-using-scp-or-ssh
import os
import paramiko
ssh = paramiko.SSHClient()
ssh.load_host_keys(os.path.expanduser(os.path.join("~", ".ssh", "known_hosts")))
ssh.connect(server, username=username, password=password)
sftp = ssh.open_sftp()
sftp.put(localpath, remotepath)
@rms1000watt
rms1000watt / python-backup-delete-copy.py
Created July 28, 2016 23:26
Python script to backup, delete, copy files from the home directory to a root directory (used on Ubuntu)
import os
import glob
import time
import shutil
def main():
appPath = '/etc/appName'
date = str(int(time.time()))
folders = glob.glob('staging/*')
@rms1000watt
rms1000watt / sql-server-configuration-py-api.md
Last active July 29, 2016 15:22
SQL Server configuration for Python APIs (Used with FreeTDS-based libraries like pymssql/sqlalchemy)

Allow Python API (FreeTDS) to Communicate with SQL Server

  1. Sql Server Configuration Manager
  2. Sql Server Network Configuration
  3. Protocols for MSSQLSERVER
  4. TCP/IP Enabled (yes)
  5. Restart Sql Server

Open Ports in Firewall for SQL Server

  1. Control Panel\System and Security\Windows Firewall > Advanced Settings
  2. Inbound Rules > New Rule
@rms1000watt
rms1000watt / cli-systemd-logs.sh
Created July 29, 2016 20:17
Command Line code for Systemd Logs (Ubuntu 16.06)
# Get time
timedatectl
# Get logs since a time
sudo journalctl --since 12:30
@rms1000watt
rms1000watt / python-install-systemd-ubuntu.py
Created July 29, 2016 22:18
Python script to install Systemd configuration on Ubuntu 16.06
import os
def main():
systemdText = """
[Unit]
Description=API Server
[Service]
ExecStart=/usr/bin/python /etc/appName/api/apiServer.py
Restart=always
@rms1000watt
rms1000watt / nginx-reactjs-spa.md
Last active August 1, 2016 19:00
Nginx Configuration for ReactJS SPA web apps

Nginx configuration for ReactJS SPA web apps

This configuration is added (in the location brackets) so http://mySite.com/page1 serves files from index.html.

server {
       listen 80 default_server;
       listen [::]:80 default_server;
       root /var/www/public;
 index index.html