Skip to content

Instantly share code, notes, and snippets.

@anderser
anderser / gettag.py
Created January 26, 2012 12:01
Simple python method to retrieve title tag of external page/url - or other tags..
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import requests
def get_page_tag(url, title_re=re.compile(r'<title>(.*?)</title>', re.UNICODE )):
"""
Retrieves the title tag from a given url (or actually any tag if you want..)
@BrandonZacharie
BrandonZacharie / String.toRegExp.js
Created February 21, 2012 21:23
A JavaScript function to convert a string to a RegExp
if (!String.toRegExp)
String.toRegExp = function String_toRegExp(pattern, flags) {
return new RegExp(pattern.replace(/[\[\]\\{}()+*?.$^|]/g, function (match) { return '\\' + match; }), flags);
};
@johntyree
johntyree / getBlockLists.sh
Last active June 4, 2024 12:30
Make one large blocklist from the bluetack lists on iblocklist.com
#!/usr/bin/env sh
# Download lists, unpack and filter, write to stdout
curl -s https://www.iblocklist.com/lists.php \
| sed -n "s/.*value='\(http:.*=bt_.*\)'.*/\1/p" \
| xargs wget -O - \
| gunzip \
| egrep -v '^#'
@dmarx
dmarx / dl_reddit_saved_images.py
Created December 6, 2012 15:42
Downloads images from a user's saved links on reddit. Requires manual entry of username and password
"""
This script was written to illustrate libraries that could be used to improve upon
the efficiency of a script posted to /r/learnprogramming:
Original script:
https://github.com/aesptux/download-reddit-saved-images/blob/master/script.py
Reddit post
http://www.reddit.com/r/learnprogramming/comments/14dojd
/pythoncode_review_script_to_download_saved_images/
"""
from urllib2 import Request, urlopen
/*
* This is a very customized implementation of the jQuery File Upload plugin
* configured to work with nginx.
*/
$(function() {
var calculateProgress, cancelAllUploads, cancelUpload, createProgressBar,
fileName, files, maxChunkSize, startAllUploads, startUpload, uploadedFilePath;
// A container to hold all of the upload data objects.
#!/usr/bin/env python2
#
# Find and replace tracker urls in a Deluge torrents.state
import os
import sys
import platform
import shutil
import cPickle
@kissgyorgy
kissgyorgy / download_file.py
Last active November 15, 2022 10:38
Python: Download file, get file size and Content type.
import requests
r = requests.get("http://download.thinkbroadband.com/10MB.zip",
cookies={'cookie1': 'working'}
)
open('10MB.zip', 'wb').write(r.content)
@plentz
plentz / nginx.conf
Last active July 22, 2024 11:19
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@hofmannsven
hofmannsven / README.md
Last active July 16, 2024 01:30
Git CLI Cheatsheet
@EronHennessey
EronHennessey / check4siteupdate.py
Created October 15, 2013 18:21
A Python script that checks the last-modified date of a URL against the last-modified date of a previous look at it. If the last-modified date has changed, it emails the designated address, saying so. This could be used as a cron job to periodically check for updates of any page on the internet.
# check for an update on a web-page, and email the user
import httplib
import sys
import pickle
from datetime import datetime
import smtplib
from email.mime.text import MIMEText
import yaml
def email_user(cur_data, email_from, email_to):