Skip to content

Instantly share code, notes, and snippets.

Luc Sarzyniec olbat

View GitHub Profile
View worker.js
// https://developers.cloudflare.com/workers/about/
// https://tutorial.cloudflareworkers.com
//
// A Service Worker which adds Security Headers.
// Checks:
// https://securityheaders.io/
// https://observatory.mozilla.org/
// https://csp-evaluator.withgoogle.com/
// https://hstspreload.org/
// https://www.ssllabs.com/ssltest/
@olbat
olbat / Coursera-Cryptography-I.md
Created Aug 18, 2018 — forked from misho-kr/Coursera-Cryptography-I.md
Summary of Cryptography-I course at Coursera.Org
View Coursera-Cryptography-I.md

Cryptography I

Cryptography is an indispensable tool for protecting information in computer systems. This course explains the inner workings of cryptographic primitives and how to correctly use them. Students will learn how to reason about the security of cryptographic constructions and how to apply this knowledge to real-world applications. More ...

Week 1

This week's topic is an overview of what cryptography is about as well as our first example ciphers. You will learn about pseudo-randomness and how to use it for encryption. We will also look at a few basic definitions of secure encryption.

Introduction

View crypto-coursera.org
@olbat
olbat / crypto-week-one.md
Created Aug 9, 2018 — forked from siddMahen/crypto-week-one.md
Coursera cryptography lecture notes, from week one.
View crypto-week-one.md

Crypto Notes Week 1

The first half of the course will be about sym. enc. and the second half will be about public key enc.

Introduction and Prereqs

What is cryptography?

The core of cryptography is about:

  • establishing a secret key between two parties
@olbat
olbat / strpreprocess.py
Last active Mar 20, 2018
Python string pre-processing for ML
View strpreprocess.py
#!/usr/bin/python3
import sys
import unicodedata
import regex # https://pypi.python.org/pypi/regex/
SPECIAL_CHARS = r"\-'" # FIXME: French specific
RE_WHITESPACES = regex.compile(r"\p{Zs}+")
RE_SENTENCE_TERMS = regex.compile(r" *\p{STerm}+ *")
@olbat
olbat / plot-histograms.py
Last active Mar 19, 2018
Python3 matplotlib script that plots histograms with data from text files (one number per line)
View plot-histograms.py
#!/usr/bin/python3
"""
usage: {} title data.txt [data2.txt ...] > histogram.png
"""
import sys
import math
import os.path
import matplotlib
matplotlib.use('Agg')
@olbat
olbat / features-histogram.py
Last active Nov 24, 2017
Python3 matplotlib script that plots histograms for features of an ML corpus
View features-histogram.py
#!/usr/bin/env python3
"""
usage: {} < corpus.json > plot.pdf
The corpus file must contain one JSON document per line,
features must be stored in a field names "{}",
classes in a field names "{}".
"""
import sys
@olbat
olbat / time_measure.rb
Last active Nov 10, 2017
Ruby time measurement (monotonic)
View time_measure.rb
module Time::Measure
refine Time.singleton_class do
def measure(&_block)
tstart = Process.clock_gettime(Process::CLOCK_MONOTONIC)
yield if block_given?
(Process.clock_gettime(Process::CLOCK_MONOTONIC) - tstart)
end
end
end
@olbat
olbat / process_kill_recursive.rb
Last active Oct 21, 2017
Ruby recursive Process.kill
View process_kill_recursive.rb
module Process::KillRecursive
refine Process.singleton_class do
def children(pid)
pids = nil
if RbConfig::CONFIG['host_os'] =~ /linux/i
if File.exist?("/proc/#{pid}/task/#{pid}/children")
pids = File.read("/proc/#{pid}/task/#{pid}/children").split(/\s/)
end
elsif !Gem.win_platform?
pids = `ps --ppid #{pid} -o pid=`.split("\n")
@olbat
olbat / break_iterator_bench.cr
Created May 19, 2017
Small BreakIterator benchmark for icu.cr
View break_iterator_bench.cr
require "benchmark"
require "./src/icu"
REPEAT=1_000
# from https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt
samples = [] of String
samples << <<-EOS
Σὲ γνωρίζω ἀπὸ τὴν κόψη
τοῦ σπαθιοῦ τὴν τρομερή,
You can’t perform that action at this time.