Skip to content

Instantly share code, notes, and snippets.

View richard-to's full-sized avatar

Richard To richard-to

View GitHub Profile
@richard-to
richard-to / gist:8797504
Created February 4, 2014 03:01
Google App Script to parse specific emails and write to Google Sheets
// Modified from http://pipetree.com/qmacro/blog/2011/10/automated-email-to-task-mechanism-with-google-apps-script/
// Globals, constants
var LABEL_PENDING = "pending";
var LABEL_DONE = "done";
// processPending(sheet)
// Process any pending emails and then move them to done
function processPending_(sheet) {
@richard-to
richard-to / x11_screen_grab.cpp
Created April 7, 2014 10:30
X11 Example code for grabbing screenshots of window and sending key events
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <X11/Xlib.h>
@richard-to
richard-to / gist:cbab2ec06345a2d6b48c3354088ae168
Created February 21, 2021 02:23
Gitlab Collapse Markup - Details/Summary
<p>
<details>
<summary>Click this to collapse/fold.</summary>
These details <em>remain</em> <strong>hidden</strong> until expanded.
<pre><code>PASTE LOGS HERE</code></pre>
</details>
</p>
@richard-to
richard-to / gist:546a17276dceb087b5a5a3662618dc0f
Created February 21, 2021 02:22
Git reset master to origin
git checkout -B master origin/master
conda create --name name python=3.7
conda activate name
conda deactivate
alembic init
alembic revision --autogenerate -m "Migration comment"
alembic upgrade head
@richard-to
richard-to / import_bookmarks_to_evernote.py
Created August 21, 2013 10:12
Quick and dirty script to import bookmarks into Evernote. Expected bookmarks file is in Delicious format. In my case, I needed to export Diigo bookmarks into Evernote.
from xml.sax.saxutils import escape
from datetime import datetime
from bs4 import BeautifulSoup
headerXml = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export3.dtd">
<en-export application="Evernote" version="Evernote Mac">"""
footerXml = "</en-export>"
@richard-to
richard-to / simple_calc_with_vars.jison
Created December 24, 2013 06:30
Simple calculator language with variable substitution using jison
%lex
%{
var parser = yy.parser;
%}
%%
\n return 'NEWLINE'
\s+ /* skip whitespace */
@richard-to
richard-to / sklearn_algorithms.py
Created December 6, 2014 00:26
Testing out some classifiers using Scikit Learn (Random Forests, SVC, Multinomial NB, Logistic Regression)
import csv
import numpy as np
from sklearn.cross_validation import KFold
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer
from sklearn.feature_selection import SelectPercentile, f_classif
from sklearn.metrics import accuracy_score, precision_recall_fscore_support
from sklearn.pipeline import Pipeline
from sklearn.svm import SVC
from sklearn.ensemble import RandomForestClassifier
from sklearn.naive_bayes import MultinomialNB