Skip to content

Instantly share code, notes, and snippets.

import multiprocessing as mp
def worker(filex):
""" reading lots of data """
raw = filter(lambda x: len(x.split())>3,
open(filex).readlines())
data = {}
# putting all the data in the data dictionary
return data
@phihag
phihag / addresses.log
Created July 11, 2014 06:56
OpenVPN problem - Why is the default gateway 10.222.0.5?
# On the server:
$ ip a s dev tun0
15: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 100
link/none
inet 10.222.0.1 peer 10.222.0.2/32 scope global tun0
# Client output:
...
Fri Jul 11 08:55:32 2014 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 2048 bit RSA
Fri Jul 11 08:55:32 2014 [n.phihag.de] Peer Connection Initiated with [AF_INET]174.34.171.91:1194
@phihag
phihag / filehandles.go
Created April 29, 2014 11:17
Demo file for file handle count question on so
package main
import "fmt"
import "io/ioutil"
func main() {
files, _ := ioutil.ReadDir("/tmp/files")
for _, file := range files {
_, err := ioutil.ReadFile("/tmp/files/" + file.Name())
@phihag
phihag / gist:8422290
Created January 14, 2014 17:32
badnet.info-Fehlermeldung
Zugriff verweigert
Dir wurde der Zugriff auf diese Seite auf Grund eines Cross-Site Scripting-Angriffs (XSS) in der Variable $_POST::password verwehrt.
Bitte klicke hier oder benutze die Zurück-Funktion deines Browsers, um zur Ursprungsseite zurückzukehren!
username phihag
email phihag@phihag.de
confirmEmail phihag@phihag.de
password Y8XEz<FMQ$V0+:)6]sC`KTr}*&"D<=`}
confirmPassword Y8XEz<FMQ$V0+:)6]sC`KTr}*&"D<=`}
ye5b0afbd37a83f9 jd5970706b26931ef
@phihag
phihag / gist:8380598
Created January 12, 2014 03:54
Article about open
The open function explained
[open](http://docs.python.org/dev/library/functions.html#open) opens a file. Pretty simple, eh? Most of the time, we see it being used like this:
[sourcecode language='python']
f = open('photo.jpg', 'r+')
jpgdata = f.read()
f.close()
[/sourcecode]
@phihag
phihag / client-server-example.py
Created January 10, 2014 11:52
Example for python client/server
from socket import *
from threading import Thread
import threading
import time
from random import randint
clients = []
HOST = 'localhost'
PORT = 8000
@phihag
phihag / RawDataeDataTest.csv
Created October 18, 2013 09:30
Demonstration of csv sorting
text text text 11/03/12 text text text UniqueNameClass1 text text
text text text 11/03/12 text text text UniqueNameClass2 text text
text text text 11/03/12 text text text UniqueNameClass4 text text
text text text 11/03/12 text text text UniqueNameClass3 text text
text text text 11/03/12 text text text UniqueNameClass1 text text
text text text 11/03/12 text text text UniqueNameClass2 text text
text text text 11/03/12 text text text UniqueNameClass5 text text
text text text 11/03/12 text text text UniqueNameClass1 text text
text text text 11/03/12 text text text UniqueNameClass1 text text
text text text 12/03/12 text text text UniqueNameClass5 text text
@phihag
phihag / shell-log
Last active December 19, 2015 03:48
$ wget https://yt-dl.org/latest/youtube-dl && chmod a+x youtube-dl && ./youtube-dl http://vimeo.com/groups/124584/videos/24973060 -v
--2013-06-29 20:52:13-- https://yt-dl.org/latest/youtube-dl
Resolving yt-dl.org (yt-dl.org)... 95.143.172.170, 2001:1a50:11:0:5f:8f:acaa:177
Connecting to yt-dl.org (yt-dl.org)|95.143.172.170|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 137063 (134K) [application/octet-stream]
Saving to: ‘youtube-dl’
100%[=====================================================================================================================>] 137,063 558KB/s in 0.2s
#!/usr/bin/env python3
import urllib.request
url = 'http://www.myspace.com/Modules/PageEditor/Handlers/Music/SearchMusic.ashx'
data = b'term=incomplete&maxArtists=10&maxSongs=20'
headers = {
'Hash':'MIGcBgkrBgEEAYI3WAOggY4wgYsGCisGAQQBgjdYAwGgfTB7AgMCAAECAmYDAgIAwAQIYLI97pYniaIEEEZ7OzdEz%2bIWLU44SUNWb30EUFjzQCE6jLLj9dgPm5be2u4N4ljriq5Up6l3RTd81ynC8UyNrmT8KElNy5%2bz8uxPHY3FdSDSgkJUuW3iF4SdT53bMvA8fAP2iOBxBMhGjy9d',
}
req = urllib.request.Request(url, data, headers)
<!DOCTYPE html>
<html>
<body>
<?php
var_export($_POST);
?>
<form method="post" name="thumbnail">
<input type="hidden" value="202" id="id_recipe" name="id_recipe">