Skip to content

Instantly share code, notes, and snippets.

View clausd's full-sized avatar

Claus Dahl clausd

View GitHub Profile
sudo stdbuf -oL -eL /usr/bin/tcpdump -i lo -A -s 10240 "tcp port 10000 " | egrep -a --line-buffered ".+(GET |HTTP\/|POST )|^[A-Za-z0-9-]+: " | perl -nle 'BEGIN{$|=1} { s/.*?(GET |HTTP\/[0-9.]* |POST )/\n$1/g; print }'
@clausd
clausd / gist:e872308c03117e232b36cadfa72ac2ac
Created April 30, 2020 11:43
Neat Markdown from epub (google docs)
pandoc --from=epub+native_divs+native_spans --to=rtf source.epub | unrtf | pandoc --from=html-native_divs-native_spans --to=markdown_strict > acceptable.md
@clausd
clausd / cheatsheet.py
Created September 30, 2018 21:16
Python basics
# variables hold values the user enters
# we also use them to guide program flow
# by the way - these are comments. They start with # - after that the rest of the line is ignored
number = 1 # define a variable
string = "Some text" # a string is a variable containing text
list = [1,2,3,4] # we can also define lists of things
number = 2 # changing the value of a variable
number = number + 1 # we can use the variable itself, any expression, to set the new value. The value of number is now 3
@clausd
clausd / howto.txt
Created July 3, 2018 11:22
Flask on Dokku on Digitalocean
Install the Dokku droplet - smallest possible digitalocean vm works fine
Make sure you add your ssh key so you can git over ssh and ssh into the image later
* On the image be sure to NOT set up IPv6
Boot the image - note the ip
Add a star alias on some domain you control and point it at that ip address - this lets you dokku up a lot of projects at somedomain.yourdomain.com
Go to http://[your IP address] to finalize dokku setup - set up virtual domains to make use of the star alias you just made
* You need to add your ssh public key here as well
* You CANNOT just add your key to authorised_keys - you need to use sshcommand - this enables the whole 'push to deploy' workflow
Follow the Flask-y steps here https://www.linode.com/docs/applications/containers/deploy-a-flask-application-with-dokku/
@clausd
clausd / helloworld.py
Last active January 14, 2017 17:24
Just the code from Keras Helloworld
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from sklearn.cross_validation import train_test_split
from sklearn.linear_model import LogisticRegressionCV
from keras.models import Sequential
from keras.layers.core import Dense, Activation
from keras.utils import np_utils
@clausd
clausd / watch.py
Created December 20, 2016 13:26
How to do LDA in python (for Morten)
import numpy as np
import pandas as pd
import lda
import lda.datasets
from sklearn.feature_extraction.text import CountVectorizer
def load_questions():
sheet = pd.read_excel('android_watch.xlsx')
Qs = sheet['Question']
@clausd
clausd / mixpanel.py
Last active September 7, 2016 10:12
#! /usr/bin/env python
#
# Mixpanel, Inc. -- http://mixpanel.com/
#
# Python API client library to consume mixpanel.com analytics data.
#
# Copyright 2010-2013 Mixpanel, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
class IntrospectBinding
attr_accessor :binding, :evals
def initialize(binding)
@binding = binding
@evals = []
end
def eval(string, filename = '', lineno = 0)
@clausd
clausd / build_it.rb
Created March 3, 2016 14:28
Just want to expand some values into static files - not a "blog engine". This is already overkilll
#!/usr/bin/ruby
require 'erb'
require 'json'
require 'yaml'
require 'fileutils'
@from = ARGV.shift || 'files'
@to = ARGV.shift || 'dist'
# definitions
@clausd
clausd / exsql.py
Last active March 2, 2016 08:06
Excel to Mysql
import argparse
import pandas as pd
import mysql.connector
from sqlalchemy import create_engine
from string import Template
import os
import argparse
parser = argparse.ArgumentParser()