Skip to content

Instantly share code, notes, and snippets.

View ondrejsika's full-sized avatar
🦃
Working on my courses

Ondrej Sika ondrejsika

🦃
Working on my courses
View GitHub Profile
@ondrejsika
ondrejsika / csrf.js
Last active August 29, 2015 14:11 — forked from bengolder/csrf.js
var jQuery = window.aaa$;
// using jQuery
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
ADD RULE with PORT and IPADDRESS
sudo iptables -A INPUT -p tcp -m tcp --dport port_number -s ip_address -j ACCEPT
ADD RULE for PORT on all addresses
sudo iptables -A INPUT -p tcp -m tcp --dport port_number --sport 1024:65535 -j ACCEPT
DROP IPADRESS
sudo iptables -I INPUT -s x.x.x.x -j DROP
VIEW IPTABLES with rule numbers
@ondrejsika
ondrejsika / dns.py
Last active August 29, 2015 14:17 — forked from johnboxall/dns.py
# http://notmysock.org/blog/hacks/a-twisted-dns-story.html
# http://blog.inneoin.org/2009/11/i-used-twisted-to-create-dns-server.html
# twistd -y dns.py
import socket
from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor
from twisted.names import dns
from twisted.names import client, server
from collections import Mapping
from twisted.names import dns, server, client, cache
from twisted.application import service, internet
class MapResolver(client.Resolver):
def __init__(self, mapping, servers):
client.Resolver.__init__(self, servers=servers)
@ondrejsika
ondrejsika / admin.py
Last active August 29, 2015 14:18 — forked from mattlong/admin.py
from functools import update_wrapper
from django.contrib import admin
from django.contrib.admin import ModelAdmin
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
from django.core.exceptions import PermissionDenied
from django.shortcuts import render
from myapp.models import Widget
from myapp.forms import ManageWidgetForm
import hashlib
import struct
####http://python-bitcoinlib.readthedocs.org/en/latest/_modules/bitcoin/core/serialize.html
def uint256_from_str(s):
"""Convert bytes to uint256"""
r = 0
t = struct.unpack(b"<IIIIIIII", s[:32])
for i in range(8):
r += t[i] << (i * 32)
#!/usr/bin/env python
# coding: utf-8
# http://musta.sh/2012-03-04/twisted-tcp-proxy.html
import sys
from twisted.internet import defer
from twisted.internet import protocol
from twisted.internet import reactor
from twisted.python import log
@ondrejsika
ondrejsika / .htaccess
Created September 7, 2016 13:26 — forked from oaltman/.htaccess
QR platba
RewriteEngine on
RewriteRule ^([0-9]+)/(.*)$ index.php?castka=$1&msg=$2 [L]
RewriteRule ^([0-9]+)$ index.php?castka=$1%
@ondrejsika
ondrejsika / readme.md
Created March 19, 2019 19:42 — forked from ubergesundheit/readme.md
systemd traefik.service

systemd Service Unit for Traefik

Adapted from traefik systemd Service Unit

The provided file should work with systemd version 219 or later. It might work with earlier versions. The easiest way to check your systemd version is to run systemctl --version.

Instructions

We will assume the following:

Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)