Skip to content

Instantly share code, notes, and snippets.

@DominicBreuker
DominicBreuker / GnuPG.md
Created October 31, 2017 22:03
gpg gnupg encryption

GnuPG

Setup

Install:

brew install gnupg # on Mac OS
apt-get install gnupg # on Ubuntu/Debian
...
@DominicBreuker
DominicBreuker / iptables.md
Last active October 14, 2021 17:47
iptables firewall

iptables cheat sheet

Concepts

iptables defines tables, which group features:

  • filter: use it to filter traffic
  • nat: use it to implement NAT
  • raw: use it to define which connections iptables should track (stateful firewall)
  • mangle: use it to change some fields in packets (e.g., TTL)
  • security: use it to define access control
# delete all containers
docker rm $(docker ps -a -q)
# delete images without tags
docker rmi $(docker images | grep '^<none>' | awk '{print $3}')
# clean up volumnes
docker volume prune
@DominicBreuker
DominicBreuker / word2vec_kata.py
Created June 17, 2016 11:13
Fill in some lines of code and train your word vectors
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@DominicBreuker
DominicBreuker / sgd.py
Last active January 6, 2020 08:51
Simple SGD example for tensorflow
import tensorflow as tf
from random import randint, seed
seed(42)
current_x = tf.placeholder(tf.float32)
x = tf.Variable(2.1, name='x', dtype=tf.float32)
log_x = tf.log(x)
result = current_x * tf.square(log_x)
import tensorflow as tf
x_1 = tf.placeholder(tf.float32)
x_2 = tf.placeholder(tf.float32)
x_3 = tf.placeholder(tf.float32)
x = tf.Variable(2, name='x', dtype=tf.float32)
log_x = tf.log(x)
result = (x_1 + x_2 + x_3) * tf.square(log_x)
@DominicBreuker
DominicBreuker / gd_simple.py
Created June 16, 2016 16:30
Simple example of gradient descent in tensorflow
import tensorflow as tf
x = tf.Variable(2, name='x', dtype=tf.float32)
log_x = tf.log(x)
log_x_squared = tf.square(log_x)
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(log_x_squared)
init = tf.initialize_all_variables()
@DominicBreuker
DominicBreuker / contact_me.js
Last active April 10, 2016 18:12
gs_spreadsheet_example
...
$.ajax({
url: "https://script.google.com/macros/s/AKfycbz4aFabJ80gajXFBcXlFLpR6n9ad9GHs4UcT6ux9w7RAYcI_9w/exec",
// this was 'url: "././mail/contact_me.php"'
type: "POST",
data: {
name: name,
phone: phone,
email: email,
message: message
@DominicBreuker
DominicBreuker / code.js
Created April 9, 2016 08:57
Google Spreadsheet Form Backend
function registerSheetWithScript() {
...
SpreadsheetApp.getUi().alert('This sheet will now receive data from forms!');
}
function onOpen() {
SpreadsheetApp.getUi().createMenu('FormBackend')
.addItem('Register sheet', 'registerSheetWithScript')
.addToUi();
}
<script data-cfasync="false" type="text/javascript">
jQuery( document ).ready(function( $ ) {
var request;
$("#my_form").submit(function(event){
if (request) { request.abort(); }
$('#result').text('Sending data...');
request = $.ajax({
url: "https://script.google.com/macros/s/AKfycbz4aFabJ80gajXFBcXlFLpR6n9ad9GHs4UcT6ux9w7RAYcI_9w/exec",