Skip to content

Instantly share code, notes, and snippets.

View freeatnet's full-sized avatar
🕊️
make trustless systems not war

Arseniy Ivanov freeatnet

🕊️
make trustless systems not war
View GitHub Profile
@freeatnet
freeatnet / create_site.sh
Created March 11, 2010 19:09
A simple scripts that takes away the pain of creating VirtualHosts on my home Ubuntu server w/ Apache2
#!/bin/bash
# A simple scripts that takes away the pain of creating VirtualHosts on my home Ubuntu server w/ Apache2
# by Arseniy Ivanov, freeatnet.com
WWW_ROOT='/var/www/'
SITE_CONFS='/etc/apache2/sites-available/'
host_name=''
@freeatnet
freeatnet / twitlinesender.py
Created May 19, 2010 08:04
A _very_ simple script that allows sending a file line-by-line as your tweets. Deletes line sent from file. Easy to hook up to Cron. Uses Basic auth.
#!/bin/bash
# Usage: twitlinesender.py <lines.txt>
API_URL="http://api.twitter.com/1"
API_USER="YOUR_TWITTER_USERNAME"
API_PASSWORD="YOUR_TWITTER_PASSWORD"
value=`cat $1 | head -n 1`
encoded_value=`python -c "import urllib; print urllib.quote('''$value''')"`
@freeatnet
freeatnet / dbschema.sh
Created June 22, 2010 09:33
Straightforward script to keep MySQL DB schema sql file in a project under SVN control
PROJECT_NAME='PROJECT_NAME'
MYSQL_HOST='localhost'
MYSQL_DB='website'
MYSQL_USERNAME='root'
MYSQL_PASS='toor'
wc_rev=`svn info | grep "Revision" | cut -d ' ' -f2`
backup_stamp=$PROJECT_NAME'-'`date +"%d-%m-%Y_%H-%M"`'-r'$wc_rev'.sql'
require 'rubygems'
require 'oauth'
require 'yaml'
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
def get_access_token
p "get_access_token: Initializing Consumer"
consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, {
import cookielib
import gzip
import httplib
import StringIO
import urllib
import urllib2
class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
def http_error_301(self, req, fp, code, msg, headers):
result = urllib2.HTTPRedirectHandler.http_error_301(
@freeatnet
freeatnet / resolver.py
Last active December 10, 2015 21:38
Resolver.py -- a simple class that allows you to get to the canonical URL by following redirects, meta refresh tags, and rel="canonical" tags. Written for Python 2.7 using requests library. Beta-quality at the moment. Inspired by https://github.com/scottwater/unwind.
import logging
import re
import urlparse
import requests
class Resolver:
re_canonical = re.compile('<link rel=[\'\"]canonical[\'\"] href=[\'\"](.*?)[\'\"]', re.IGNORECASE)
javascript:(function(){var%20syntaxHighlight=function(json){json=json.replace(/%26/g,'%26amp;').replace(/%3C/g,'%26lt;').replace(/%3E/g,'%26gt;');return%20json.replace(/(%22(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\%22])*%22(\s*:)%3F|\b(true|false|null)\b|-%3F\d+(%3F:\.\d*)%3F(%3F:[eE][+\-]%3F\d+)%3F)/g,%20function%20(match)%20{var%20cls='number';if(/^%22/.test(match))%20{if(/:$/.test(match)){cls='key';}else{cls='string';}}else%20if(/true|false/.test(match)){cls='boolean';}else%20if(/null/.test(match)){cls='null';}return%20'%3Cspan%20class=%22'%20+%20cls%20+%20'%22%3E'+match+'%3C/span%3E';});};var%20xhr=new%20XMLHttpRequest();var%20params=%22url=%22+encodeURIComponent(document.location.toString())+%22%26content=%22+encodeURIComponent(document.documentElement.innerHTML);xhr.open(%22POST%22,%22https://staging.trycurio.com/extractor/check%22,true);xhr.setRequestHeader(%22Content-Type%22,%22application/x-www-form-urlencoded%22);xhr.onreadystatechange=function(){if(this.readyState==4%20%26%26%20this.status==200){var%20temp=do
@freeatnet
freeatnet / gist:6349739
Created August 27, 2013 04:53
dig 500px.com
dig 500px.com upload.500px.com pcdn.500px.net any a; dig 500px.com upload.500px.com pcdn.500px.net any a +cd
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.