View Unprotect-ProtectedData.ps1
Add-Type -AssemblyName System.Security;
[Text.Encoding]::ASCII.GetString([Security.Cryptography.ProtectedData]::Unprotect([Convert]::FromBase64String((type -raw (Join-Path $env:USERPROFILE foobar))), $null, 'CurrentUser'))
View lastfm-remove-duplicates.js
var elements = Array.from(document.querySelectorAll('.js-link-block'))
elements.map(function (element) {
var nameElement = element.querySelector('.chartlist-name')
return nameElement && nameElement.textContent.replace(/\s+/g, ' ').trim()
}).forEach(function (name, i, names) {
if (name !== names[i + 1]) return
var deleteButton = elements[i].querySelector('[data-ajax-form-sets-state="deleted"]')
if (deleteButton) deleteButton.click()
location.reload()
})
View vagrant-cheat-sheet.md

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
View secrets_management.md

Rails secrets management with Figaro and Capistrano

Use of figaro gem (or something like dotenv) in all environments.

The Figaro config/application.yml file with all the secrets will be git-ignored. So on every deployment server I had to manually add the file shared/config/application.yml and then linked automatically on each deployment to the current version of the app by adding in config/deploy.rb:

set :linked_files, %w{config/application.yml}

For development config/application.yml is something like the following:

View openai-gym-mcts.py
#!/usr/bin/env python2
import os
import gym
import sys
import random
import itertools
from time import time
from copy import copy
from math import sqrt, log
View email.js
import express from 'express';
import path from 'path';
import isEmpty from 'lodash/isEmpty';
import mailer from 'express-mailer';
import dotenv from 'dotenv';
dotenv.load();
const app = express();
const router = express.Router();
View pm2.sh
#!/bin/sh
: ${pm2_user="root"}
command="/usr/local/lib/node_modules/pm2/bin/pm2"
pidfile="/home/${pm2_user}/.pm2/${name}.pid"
super() {
View test_client_fake_server.py
import asyncio
import pathlib
import socket
import ssl
import pytest
import aiohttp
from aiohttp import web
from aiohttp.resolver import DefaultResolver
View pmml_bayesnet.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View CustomCell.swift
class CustomCell: UITableViewCell {
@IBOutlet weak var timeRemainingLabel: UILabel!
/// Configure the cell for your model object.
///
/// Called by tableView(_:cellForRow:).
///
/// Also starts the refresh timer.
///