This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir -p /srv/iub_data | |
mkdir -p /srv/iub_mirror | |
lftp -c "open 'ftp://open.iub.gov.lv'; | |
lcd /srv/iub_data/; | |
mirror --verbose ./ /srv/iub_mirror/ " | |
cd /srv/iub_mirror | |
find ./ -name '*.tar.gz' -exec tar -xzvf {} -C /srv/iub_data \; | |
grep -hroP '(?<=<email>).*?(?=</email>)' /srv/iub_data/ | cut -d "@" -f2 | sed -e 's/^[ \t\]*//' | sort -u > ~/domain_list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# checking that we violate pep8 line numbers and pyflakes does not complain | |
(test)kristaps@dev:~/src/crawler/content$ pip freeze | grep pyflakes | |
pyflakes==0.5.0 | |
(test)kristaps@dev:~/src/crawler/content$ cat models.py | pyflakes | |
(test)kristaps@dev:~/src/crawler/content$ wc -L models.py | |
184 models.py | |
#checking that pyflakes source codez does not contain reference to 80 | 79 line numbers | |
(test)kristaps@dev:/tmp$ wget https://launchpadlibrarian.net/79102431/pyflakes-0.5.0.tar.gz | |
--2012-09-20 22:12:56-- https://launchpadlibrarian.net/79102431/pyflakes-0.5.0.tar.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" standalone='no'?><!--*-nxml-*--> | |
<!DOCTYPE service-group SYSTEM "avahi-service.dtd"> | |
<service-group> | |
<name>2 Stava printeris</name> | |
<service> | |
<type>_ipp._tcp</type> | |
<subtype>_universal._sub._ipp._tcp</subtype> | |
<port>631</port> | |
<txt-record>txtver=1</txt-record> | |
<txt-record>qtotal=1</txt-record> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$host = ""; | |
$user = ""; | |
$pass = ""; | |
$file = "" | |
$link = mysql_connect($host, $user, $pass); | |
mysql_query("set names utf8;"); | |
mysql_query("USE truevision"); | |
$file = file_get_contents($file); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io" | |
"http" | |
"fmt" | |
) | |
func main() { | |
r, _, err := http.Get("http://www.websvarki.lv/") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find sum of all non-prime numbers in range(100) | |
def eulers_sieve(n): | |
c = range(n+1) | |
fin = int(n**0.5) | |
for i in xrange(2, fin+1): | |
if not c[i]: | |
continue | |
c[2*i::i] = [None] * (n//i - 1) | |
return [i for i in c[2:] if i] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpRequest | |
# Safari default security policy restricts cookie setting in first request in iframe | |
# Solution is to create hidden form to preserve GET variables and REPOST it to current URL | |
class IFrameFixMiddleware(object): | |
""" middleware fixes sessions with Safari browser in iframes """ | |
def process_request(request): | |
if request.META['HTTP_USER_AGENT'].find('Safari') != -1 and 'sessionid' not in request.COOKIES and 'cookie_fix' not in request.GET: | |
html = """<html><body><form name='cookie_fix' method='GET' action='.'>""" | |
for item in request.GET: | |
html += "<input type='hidden' value='%s' name='%s' />" % (request.GET[name], name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <evhttp.h> | |
void process_request(struct evhttp_request *req, void *arg){ | |
struct evbuffer *buf = evbuffer_new(); | |
if (buf == NULL) return; | |
evbuffer_add_printf(buf, "Requested: %s\n", evhttp_request_uri(req)); | |
evhttp_send_reply(req, HTTP_OK, "OK", buf); | |
} | |
int main () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@login_required | |
def search(request): | |
term = request.GET.get('term', None) | |
context = RequestContext(request) | |
context['search_term'] = term | |
if term is None: | |
context['results'] = SearchQuerySet().none() | |
context['search_term'] = '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /index.php [L] | |
</IfModule> |
NewerOlder