Skip to content

Instantly share code, notes, and snippets.

View sn1p3r46's full-sized avatar
💭
Lost in Coding

Alexander Ows sn1p3r46

💭
Lost in Coding
View GitHub Profile
@sn1p3r46
sn1p3r46 / AprioriCompact.py
Created January 28, 2016 13:37
a compact apriori pythonian version
from collections import defaultdict
from itertools import imap, combinations
def get_frequent_items_sets(transactions,min_support,steps=0):
frequent_itemsets = []
items = defaultdict(lambda: 0)
[inc(items,item,1) for transaction in transactions for item in transaction]
items = set(item for item, support in items.iteritems()
if support >= min_support)
[frequent_itemsets.append(item) for item in items]
@sn1p3r46
sn1p3r46 / TP-Link_TD-W8960N_Reboot.sh
Last active November 29, 2020 15:23
This bash script reboots TP-Link routers
[ -z "$PS1" ] && return
export EDITOR=/usr/bin/nano
export SHELL=/bin/bash
# Pretty-print of some PATH variables:
alias path='echo -e ${PATH//:/\\n}'
alias libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'
alias mkdir='mkdir -p'
@sn1p3r46
sn1p3r46 / preprocessing.pl
Last active June 26, 2016 18:11
TEXT PREPROCESSING WITH PERL
#!/usr/bin/perl
my @myLangs = qw( de it fr );
# STOP WORDS FOLDER
my $stp = "/home/andrea/Downloads/DataMining/code/data/";
# STOP WORDS FILE
my $stf = "/stopwords.txt";
# DATA MAIN PATH
@sn1p3r46
sn1p3r46 / Animal.java
Last active September 26, 2016 18:18
Basic Java class for java teaching proposes :)
// The class is visible from outside the package
// the class itself is not the object but is the
// description of its behaviour and its data structure.
// (The PROJECT)
public class Animal {
private String race = "Uknown";
private int age;
@sn1p3r46
sn1p3r46 / exercises0.erl
Last active November 16, 2016 00:25
Erlang functional programming exercises;
%%% Exercises description on comments;
-module(exercises0).
-export([count/1,repeated_elems/1,most_frequent_elem/1,ntimes/3]).
%%% #1
count([H|T]) ->
count([H|T],[]);
count([]) -> [].
@sn1p3r46
sn1p3r46 / LatexPro.tex
Last active June 12, 2017 20:14
Array with overlapping windows
% https://www.overleaf.com/9963466dzbgyfnsjpmx#/36591581/
\documentclass{article}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength{\PreviewBorder}{10pt}%
\usetikzlibrary{patterns,decorations.pathreplacing}
\usetikzlibrary{snakes}
@sn1p3r46
sn1p3r46 / index.html
Last active September 14, 2017 19:23
Simple WebSocket Client-Server Example
<!DOCTYPE html>
<html>
<head>
<title>WebSocket demo</title>
</head>
<body>
<script>
var messages = document.createElement('ul');
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@sn1p3r46
sn1p3r46 / README.md
Created November 17, 2017 22:11 — forked from gdamjan/README.md
Setup for an easy to use, simple reverse http tunnels with nginx and ssh. It's that simple there's no authentication at all. The end result, a single ssh command invocation gives you a public url for your web app hosted on your laptop.

What

A lot of times you are developing a web application on your own laptop or home computer and would like to demo it to the public. Most of those times you are behind a router/firewall and you don't have a public IP address. Instead of configuring routers (often not possible), this solution gives you a public URL that's reverse tunnelled via ssh to your laptop.

Because of the relaxation of the sshd setup, it's best used on a dedicated virtual machine just for this (an Amazon micro instance for example).

Requirements