Skip to content

Instantly share code, notes, and snippets.

@koelling
koelling / gov_uk_paste_travel_dates.js
Last active January 6, 2020 13:19
Paste travel data from a spreadsheet into the gov.uk citizenship application pages. Make a four column spreadsheet with departure date (DD/MM/YYYY), return date, country and reason, then copy and paste the the first row into the page. The script will automatically submit the form and then return to it, ready for the next row.
// ==UserScript==
// @name gov.uk - paste travel dates
// @description Paste travel data from a spreadsheet into the gov.uk citizenship application pages. Make a four column spreadsheet with departure date (DD/MM/YYYY), return date, country and reason, then copy and paste the the first row into the page. The script will automatically submit the form and then return to it, ready for the next row. Disable the userscript when done adding additional trips.
// @match https://visas-immigration.service.gov.uk/*
// @version 1
// @grant none
// @run-at document-end
// ==/UserScript==
function fillDate(date, prefix) {
import math
#start with population of size 10k
N_AF = 10000
#when we split this into five, we should have initial size before growth of N/5 in each
N_EU0 = N_AF / 5
#the five populations merged into the ancestral population 100 generations ago
T_merge = 100
#assume growth rate of 0.4%
popA = 1
popB = 2
samplesA = [sample for sample in tree_sequence.get_samples() if tree_sequence.get_population(sample) == popA]
samplesB = [sample for sample in tree_sequence.get_samples() if tree_sequence.get_population(sample) == popB]
piA = tree_sequence.get_pairwise_diversity(samples = samplesA)
piB = tree_sequence.get_pairwise_diversity(samples = samplesB)
piAB = tree_sequence.get_pairwise_diversity(samples = samplesA + samplesB)
print(piA, piB, piAB)
#56465.569079715795 56413.38735640868 57020.29606185412
@koelling
koelling / gist:ef9b2b9d0be6d6dbab63
Last active February 7, 2017 16:21
CVE-2015-0235 (GHOST) test code
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
struct {
char buffer[1024];