Skip to content

Instantly share code, notes, and snippets.

🤜

Benjamin Kane bbkane

🤜
Block or report user

Report or block bbkane

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View explore_ff_bookmarks_file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This is just to find out how firefox bookmarks.json files are structured
__author__ = "Benjamin Kane"
__version__ = "0.1.0"
from collections import Counter, defaultdict
from functools import reduce
@bbkane
bbkane / README.md
Created Oct 15, 2018
Run an authenticated script from a cronjob (one way)
View README.md

This is for David - how to have a cronjob read passwords

Method

  • cronjob launches launcher script
  • launcher script:
    • sets environmental variables
    • launches python code
  • python code
    • reads passwords from environment
@bbkane
bbkane / pythonic_print.h
Last active Jan 30, 2018
Slow, fat, and convenient way to print from C++
View pythonic_print.h
#include <iostream>
#include <iterator>
#include <array>
#include <string>
// I think this will bloat binary size and be slower,
// but it's for convenient printing, which is worth it :)
// TODO: don't always call by value...
// Of course, I'm mostly passing ints and strings, so it's probably not too
View nvim-completion-with-conda.md
View sort_benchmarks.cpp
#include <algorithm>
#include <cassert>
#include <chrono>
#include <iostream>
#include <vector>
#include <random>
// NOTE: All iterator concepts are experimental. I'm not going
// to concentrate on them
@bbkane
bbkane / ka-lite-install.sh
Created Oct 8, 2017
Install Khan Academy Offline App
View ka-lite-install.sh
#!/bin/bash
# exit the script on command errors or unset variables
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
# https://stackoverflow.com/a/246128/295807
readonly script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@bbkane
bbkane / MarkovChain.py
Last active Jun 22, 2017
MarkovChain in SQL + Python
View MarkovChain.py
import contextlib
import sqlite3
CREATE_TABLES_SQL = """
CREATE TABLE IF NOT EXISTS word
(
id INTEGER NOT NULL,
word TEXT UNIQUE NOT NULL,
number INTEGER DEFAULT 1,
PRIMARY KEY (id)
@bbkane
bbkane / vagrant_up_debug_log.txt
Last active Apr 28, 2017
Vagrant error (2017-04-25)
View vagrant_up_debug_log.txt
vagrant.exe : INFO global: Vagrant version: 1.9.4
At line:1 char:1
+ & vagrant up --debug 2>&1 >> debug_log.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ( INFO global: Vagrant version: 1.9.4:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
INFO global: Ruby version: 2.2.5
INFO global: RubyGems version: 2.4.5.1
View spyder.desktop
[Desktop Entry]
Name=Spyder Python IDE
Comment=Edit text files
Exec=/home/ben/anaconda3/bin/spyder
Terminal=false
Type=Application
StartupNotify=true
MimeType=text/plain;
Icon=/home/ben/.local/share/applications/spyder.png
Categories=GNOME;GTK;Utility;TextEditor;
View Static Assert Type
#include <iostream>
#include <vector>
#include <string>
int main()
{
std::string i{"Hello"};
// static_assert(std::is_same<decltype(i), char>(), "Oops!");
std::vector<decltype(i)> v {i};
for(auto i: v) { std::cout << i << std::endl; }
You can’t perform that action at this time.