Skip to content

Instantly share code, notes, and snippets.

@hutt
hutt / Twitter easy API functions
Last active December 11, 2017 05:16
Some functions using the Twitter API (v1.1) e.g. getting followers count, tweets, background image etc. Written in PHP; use it and have fun!
function get_followers_count($username) {
$cache_file = CACHEDIR . 'twitter_followers_counter_' . md5 ( $username );
if (is_file ( $cache_file ) == false) {
$cache_file_time = strtotime ( '1984-01-11 07:15' );
} else {
$cache_file_time = filemtime ( $cache_file );
}
@hutt
hutt / plainnat.bst
Last active February 2, 2020 12:58
plainnat.bst LaTeX bibliography template for german publications in social sciences
%% File: `plainnat.bst'
%% A modification of `plainnat.bst' by Patrick W Daly for use with natbib package
%%
%% Modified in 2019 by Jannis Hutt
%% E-mail: jhutt@uni-potsdam.de
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN
%% archives in directory macros/latex/base/lppl.txt; either
%% version 1 of the License, or any later version.
@hutt
hutt / vorlage_textzusammenfassung.tex
Last active February 2, 2020 13:02
Vorlage für Textzusammenfassungen (Harvard-Zitierstil)
\documentclass[a4paper, 11pt]{article}
\usepackage{comment}
\usepackage{blindtext}
\usepackage{fullpage}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
@hutt
hutt / rsa.md
Last active February 2, 2020 13:04
Beispiel: Verschlüsselung mit RSA

Beispiel: Verschlüsselung mit RSA

Im Folgenden verschlüssle ich meinen Namen, die Zeichenkette jannis mittels RSA.

Funktionsweise

  1. Es werden zwei verschiedene, große Primzahlen p und q zufällig gewählt, wobei die Differenz nicht zu klein sein sollte, und das Produkt der beiden berechnet: n = p * q

  2. Dann wird ein zufälliger Wert e ermittelt, der teilerfremd (relativ prim) und kleiner als (p-1) * (q-1) ist. Zu diesem wird das modular Inverse d berechnet, so dass gilt: (e * d) mod ((p-1) * (q-1)) = 1

  3. Als öffentlicher Schlüssel gilt dann: e, n und der private Schlüssel ist: d und n. Die Primzahlen p und q können vergessen werden, aber sie sollten niemals bekannt werden.

@hutt
hutt / textBinASCII.php
Last active March 17, 2024 22:29
Convert string to binary / binary to string
<?php
/*******************************
*
* Convert Text to Binary ASCII
* oder so.
*
*******************************/
header("Content-Type: text/html; charset=utf-8");
function textBinASCII($text){
$bin = array();