Skip to content

Instantly share code, notes, and snippets.

@WPettersson
WPettersson / partial census notes
Created December 28, 2014 12:02
Notes on partial triangulation census of 3-manifold implementation
# Given FPG on n nodes
# Take tree decomposition of FPG, arbitrarily assign a root
# Let "contains" consisting of n "true" bools
# Let seen := {}
# Take root bag and assign properties as follows:
# Let bag.contains = contains
# Let bag.toAdd = bag.contents \setminus seen
# Let seen = seen + bag.contents
# Let contains = contains \setminus seen
@WPettersson
WPettersson / example.py
Created July 12, 2016 00:09
Example CPLEX python script
#/usr/bin/env python3
import cplex
# Create an instance of a linear problem to solve
problem = cplex.Cplex()
# We want to find a maximum of our objective function
problem.objective.set_sense(problem.objective.sense.maximize)

Installing CPLEX

Step 0 - Decide where you want things

You'll be installing everything into your home directory, so you might want to keep it organised. First you want to find out what your home directory is, so run cd with no directory specif ied to move to your home directory, and then run pwd to see your home directory. Mine is /home/595/wep595.

Now choose a place to install cplex. I suggest installing cplex into ~/opt/ibm/ILOG/CPLEX_Studio1263 and the python bindings into ~/cplex. Note that ~ is a common unix shortcut for your home

#!/usr/bin/env bash
REGINA_PATH=/path/to/regina
CCOPTS="-O3 -S -I/usr/include/python2.7 -I${REGINA_PATH}/engine -I${REGINA_PATH}/build/engine -I/usr/include/libxml2 -pthread -std=c++11 -DNDEBUG -fPIC -DREGINA_DLL_EXPORTS=1 -Dregina_engine_EXPORTS"
function testCompile {
file=$1
g++ ${CCOPTS} -o optimised.s ${file} || exit
g++ ${CCOPTS} -fwrapv -o notoptimised.s ${file} || exit
if ! diff optimised.s notoptimised.s &> /dev/null ; then
@WPettersson
WPettersson / uni.cpp
Created December 5, 2016 11:48
Unicode in C++
$ cat uni.cpp
#include <string>
#include <iostream>
int main(int argc, char** argv) {
std::string s("™");
std::string t("Hello world");
std::cout << t << s << std::endl;
return 0;
}
(sci-mathematics/singular-4.0.3_p5:0/0::sage-on-gentoo, ebuild scheduled for merge) pulled in by
=sci-mathematics/singular-4.0.3_p5 (Argument)
(sci-mathematics/singular-4.0.3_p3:0/0::sage-on-gentoo, installed) pulled in by
~sci-mathematics/singular-4.0.3_p3[readline] required by (sci-mathematics/sage-7.4-r3:0/0::sage-on-gentoo, ebuild scheduled for merge)
^ ^^^^^^^^
@WPettersson
WPettersson / pitch-remarks.md
Created March 10, 2017 07:53
re. Editors Lab pitch

The very obvious

Use SSL. Use it properly, talk to someone (or just google) HSTS and HPKP, and manage the certificates and keys properly. Rotate keys and certificates. Check your site(s) with ssllabs.com. This will probably be the hardest to manage if you want to post the form on big name news sites, as they probably have their own SSL workflow.

You're trusting keybase.io. Be aware of this, it's part of your trust model. Look at how they do security. Will you check on them from time to time? Will end users/whistleblowers be able to trust them easily? What security precautions do they use?

Metadata!

So, when people use this product our servers will never even see the message. The encryption happens right in the browser so there's no chance that anyone but the intended recipient (who controls the private key) can read the message.

@WPettersson
WPettersson / README.me
Last active March 24, 2017 11:15
Scripts to generate download speed test graphs
# Scripts to generate pretty graphs
### Outline
Use create.sh to initialise an empty database
Add test.sh to a cron job. It runs the tests at the time you specify. My crontab looks like
17 0,4,8,12,16,20 * * * /path/to/test.sh
This runs every 4 hours. There are possibly better ways to do this.
@WPettersson
WPettersson / testcase.log.txt
Created June 20, 2017 23:30
Timing results of CPLEX Python API adding linear constraints by name, by index, or by creating an LP file
2017-06-21 09:20:44,754 INFO:__main__ Using 100 constraints
2017-06-21 09:20:44,755 INFO:__main__ Average constraint size: 602.970000
2017-06-21 09:20:44,759 INFO:__main__ Using Python API starting now
2017-06-21 09:20:44,764 INFO:__main__ Sending variables to CPLEX
2017-06-21 09:20:44,790 INFO:__main__ Sending objective function to CPLEX
2017-06-21 09:20:44,792 INFO:__main__ Sending constraints to CPLEX
2017-06-21 09:20:50,662 INFO:__main__ Solving model
2017-06-21 09:20:50,728 INFO:__main__ Solution status: MIP_optimal
2017-06-21 09:20:50,729 INFO:__main__ Objective value: 100.0
2017-06-21 09:20:50,729 INFO:__main__ Using Python API starting now
print("Hello world")