Skip to content

Instantly share code, notes, and snippets.

@vtjeng
vtjeng / verify.jl
Created April 28, 2019 01:23
sample verification code for MIPVerify.jl
using MIPVerify
using Gurobi
nnparams = get_example_network_params("MNIST.WK17a_linf0.1_authors")
mnist = read_datasets("mnist")
MIPVerify.setloglevel!("info")
MIPVerify.batch_find_untargeted_attack(
nnparams,
@vtjeng
vtjeng / MIPVerify_with_gurobi
Last active November 25, 2019 06:31
Test runtime for MIPVerify package with Gurobi solver
────────────────────────────────────────────────────────────────────────────────────
Time Allocations
────────────────────── ───────────────────────
Tot / % measured: 273s / 98.7% 22.0GiB / 98.9%
Section ncalls time %tot avg alloc %tot avg
────────────────────────────────────────────────────────────────────────────────────
integration/ 1 130s 48.1% 130s 9.01GiB 41.4% 9.01GiB
sequential/ 1 130s 48.0% 130s 9.01GiB 41.4% 9.01GiB
trained_weights/ 1 84.6s 31.4% 84.6s 5.41GiB 24.9% 5.41GiB
@vtjeng
vtjeng / MIPVerify_with_cbc
Last active November 25, 2019 06:12
Test runtime for MIPVerify package with CBC solver
────────────────────────────────────────────────────────────────────────────────────
Time Allocations
────────────────────── ───────────────────────
Tot / % measured: 1795s / 100% 17.9GiB / 98.8%
Section ncalls time %tot avg alloc %tot avg
────────────────────────────────────────────────────────────────────────────────────
integration/ 1 1479s 82.5% 1479s 3.62GiB 20.4% 3.62GiB
sequential/ 1 1479s 82.5% 1479s 3.62GiB 20.4% 3.62GiB
generated_weights/ 1 1479s 82.5% 1479s 3.62GiB 20.4% 3.62GiB
@vtjeng
vtjeng / command_line_magic.md
Last active May 26, 2020 02:13
Command Line Magic

Utilities

Shell

Source Control

  • hub or ghi for working with GitHub over the command line.
  • tig for a text-mode interface to git.
@vtjeng
vtjeng / local_julia_dev.MD
Last active May 25, 2020 21:48
Guide to local development for the MIPVerify Julia Package

This is a guide for local development of a Julia package in Julia 1.0 and above.

tl;dr: We use a new environment to ensure that our regular Julia environment is not affected.

Setting up a new environment

Navigate to ~/.julia/environments. This folder should contain the default environment. (I am currently working in Julia 1.0, so the environments folder contains the folder v1.0).

From the same folder, make a new project by running julia, then entering the Pkg repl by pressing ] from julia.

Upon entering the Pkg REPL, you should see a prompt like this:

@vtjeng
vtjeng / sshd_config
Created November 21, 2020 23:06
Reasonable defaults for /etc/ssh/sshd_config
# Sources:
# https://www.digitalocean.com/community/tutorials/how-to-harden-openssh-on-ubuntu-18-04
#
PermitRootLogin no
# Limit maximum number of authentication attempts for a particular login session
MaxAuthTries 3
# Prevent certain denial-of-service attacks where multiple authentication sessions are kept open for a prolonged period of time
@vtjeng
vtjeng / absurdle.jl
Last active January 11, 2022 02:40
A proof that you need at least three guesses for https://qntm.org/wordle
# Based on https://github.com/LaurentLessard/wordlesolver
# for countmap
using StatsBase
function parse_word_list(filename::String)::Vector{String}
s = open(filename) do file
read(file, String)
end
s = replace(s, '\"' => "")
return split(s, ", ")
@vtjeng
vtjeng / anti_wordle2.py
Last active February 3, 2022 03:28
Prove adversarial wordle has no 3-move solutions, based on work by zwegner
# A shorter version of zwegner's https://gist.github.com/zwegner/508cc183ab94dd27686a40384783ca4e
# Proof of optimality of 4-move solution to adversarial Wordle
# https://qntm.org/files/wordle/index.html
import collections
with open("wordle-words.txt") as f:
normal_words = [word.strip() for word in f]
with open("wordle-fake-words.txt") as f:
@vtjeng
vtjeng / nn_wk17a_sample9.mps
Created February 24, 2023 18:16
Sample MPS file for problem where Cbc is much faster than HiGHS
This file has been truncated, but you can view the full file.
NAME
ROWS
N OBJ
L c1_2
L c2_2
L c3_2
L c4_2
L c5_2
L c6_2