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 / build.sh
Created January 18, 2015 11:18
Check endianness
gcc -o endinanness endinanness.c
@ondrejsika
ondrejsika / unicode.py
Created January 18, 2015 15:00
Principy pocitacu, test 2, otazka 2
print unichr(0x0158)+unichr(0x0065)+unichr(0x0070)+unichr(0x0061)
@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)
<div style="width:135px; height: 135px; padding: 15px; border: solid 1px; color: white; background-color: black; font-size: 30px; font-family: monospace">
Bitcoin
Blog
</div>
<hr>
<div>
<div style="width:135px; height: 135px; padding: 15px; border: solid 1px; color: white; background-color: black; font-size: 30px; font-family: monospace">
Python
#!/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