Skip to content

Instantly share code, notes, and snippets.

@richard512
richard512 / pdf2png.sh
Created November 28, 2018 05:17
Convert all PDF files in a directory to JPG files using Linux ImageMagick
convert -density 300 *.pdf -set filename:f '%t' '%[filename:f].jpg'
@richard512
richard512 / underscan_DVI.sh
Created November 28, 2018 05:05
set linux DVI output to shrink the video output to fit the screen
xrandr --output DVI-0 --set underscan on
@richard512
richard512 / VideoWriterTest.py
Created November 27, 2018 21:08 — forked from chriscollins/VideoWriterTest.py
Quick Python program for testing VideoWriter instantiation
import cv2
destination_file = 'video.avi'
fps = 10.0
size = (640, 480)
codecs = [
'4XMV',
'AASC',
'AP41',
@richard512
richard512 / web-naive-bayes.js
Created July 26, 2018 07:57
JavaScript Naive Bayes Classifier -- Web Browser Compatible
needsClassifier = (typeof Classifier === 'undefined')
if (needsClassifier) {
Classifier = class {
constructor() {
this.dict = {};
this.categories = {};
this.wordList = [];
this.categoryList = []
}
static validate(token) {
@richard512
richard512 / video2mp3.sh
Last active May 30, 2018 23:24
Linux BASH script to convert all webm and mp4 video files in a directory to mp3
for FILE in music/*.{mp4,webm}; do
if [ ! -f "${FILE%.webm}.mp3" ]; then
#echo "File not found: ${FILE%.webm}.mp3"
echo -e "Processing video '\e[32m$FILE\e[0m'";
ffmpeg -i "${FILE}" -vn -ab 128k -ar 44100 -y "${FILE%.webm}.mp3";
fi
done;
@richard512
richard512 / reddit-stylesheet-variables.htm
Created May 30, 2018 19:13
Replace Reddit Stylesheet URLs with Reddit URL Variables -- Example: url(http://...) becomes url(%%01%%)
<!--
Created using JS Bin
http://jsbin.com
Copyright (c) 2018 by anonymous (http://jsbin.com/nexafujuxu/1/edit)
Released under the MIT license: http://jsbin.mit-license.org
-->
<meta name="robots" content="noindex">
<textarea id="code">*{
@richard512
richard512 / mysql_id_column.sql
Last active May 27, 2018 02:25
MySQL Add Auto-Increment Primary Key Column (Unsigned BIGINT) to existing MySQL Table -- Useful when you want a unique identifier for each column
ALTER TABLE `tablename` ADD COLUMN id BIGINT UNSIGNED AUTO_INCREMENT, ADD PRIMARY KEY `id` (`id`)
@richard512
richard512 / airbnb-search.py
Created November 29, 2017 16:16 — forked from prehensile/airbnb-search.py
A Python script which crawls airbnb search results for a given set of keywords.
#!/usr/bin/env python
#########################
# airbnb-search.py
#########################
# by prehensile, 18/07/17
#########################
# Crawl airbnb search results (descriptions and reviews) for keywords.
# A quick, dirty and brittle set of hacks.
# Very likely to break the next time anything changes in airbnb's HTML.
@richard512
richard512 / MakeDateColumn.vba
Created October 27, 2017 01:49
Finds last column value in the first row and makes a date column from it
Sub MakeDateColumn()
If Range("A1").Value = "Date" Then
MsgBox "Already have Date column"
Exit Sub
End If
With Range("A1:Z1")
Set c = .Find(2, LookIn:=xlValues)
If Not c Is Nothing Then
strDate = c.Value
@richard512
richard512 / Append2CSV.vba
Created October 26, 2017 21:15
Append to CSV in VBA
Sub Append2CSV(CSVFile As String, CellRange As String)
Dim tmpCSV As String 'string to hold the CSV info
Dim f As Integer
f = FreeFile
Open CSVFile For Append As #f
tmpCSV = Range2CSV(Range(CellRange))
Print #f, tmpCSV
Close #f
End Sub