TODO: make gem for this
This was tested using Rails 3.2 and Rails 4.0 on Ruby 2.0.0.
-
Set the install directory for Bower components:
// .bowerrc
rules = ( | |
Rule(SgmlLinkExtractor(allow='&after=', restrict_xpaths="//p[@class='nextprev']"), | |
callback='parse_next_page', | |
follow=True, | |
), | |
) | |
def parse_next_page(self, response): | |
xpath = "//a[@class='comments']/@href" | |
requests = [Request(comment.extract() + "?limit=500", |
# Memory and cpu optimization | |
profile.set_preference('browser.sessionhistory.max_total_viewers', 0) | |
#profile.set_preference('browser.cache.memory.enable', False) | |
#profile.set_preference('browser.cache.offline.enable', False) | |
#profile.set_preference('browser.cache.disk.enable', False) | |
profile.set_preference('browser.safebrowsing.enabled', False) | |
profile.set_preference('browser.shell.checkDefaultBrowser', False) | |
profile.set_preference('browser.startup.page', 0) | |
profile.set_preference('dom.ipc.plugins.enabled.timeoutSecs', 15) | |
profile.set_preference('dom.max_script_run_time', 10) |
# -- coding: utf-8 -- | |
import os | |
import pdb | |
#import random | |
from scrapy import log, signals | |
from scrapy.stats import stats | |
from scrapy.xlib.pydispatch import dispatcher | |
from scrapy.exceptions import IgnoreRequest | |
from scrapy.conf import settings | |
from scrapy.utils.job import job_dir |
@tornado.gen.engine | |
def async_request(self, callback, server_url, method=u'GET', body=None, **kwargs): | |
""" | |
Make async request to server | |
:param callback: callback to pass results | |
:type callback: func | |
:param server_url: path to required API | |
:type server_url: unicode | |
:param method: HTTP method to use, default - GET | |
:type method: unicode |
----- Esc ----- | |
Quick change directory: Esc + c | |
Quick change directory history: Esc + c and then Esc + h | |
Quick change directory previous entry: Esc + c and then Esc + p | |
Command line history: Esc + h | |
Command line previous command: Esc + p | |
View change: Esc + t (each time you do this shortcut a new directory view will appear) | |
Print current working directory in command line: Esc + a | |
Switch between background command line and MC: Ctrl + o | |
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name |
import re | |
import htmlentitydefs | |
def convert_html_entities(s): | |
""" Convert codes like DŽ inside html document | |
into unicide characters | |
""" | |
matches = re.findall("&#\d+;", s) | |
if len(matches) > 0: | |
hits = set(matches) |
# coding: utf8 | |
""" | |
Descriptive HTTP status codes, for code readability. | |
See RFC 2616 and RFC 6585. | |
RFC 2616: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html | |
RFC 6585: http://tools.ietf.org/html/rfc6585 | |
""" | |
from __future__ import unicode_literals |
.directive( 'whenActive', function ( $location ) { | |
return { | |
scope: true, | |
link: function ( scope, element, attrs ) { | |
scope.$on( '$routeChangeSuccess', function () { | |
if ( $location.path() == element.attr( 'href' ) ) { | |
element.addClass( 'active' ); | |
} | |
else { | |
element.removeClass( 'active' ); |
# -*- coding: utf-8 -*- | |
""" | |
Download files: | |
``` | |
http://fssprus.ru/opendata/7709576929-iplegallist/data-20150415-structure-20140318.csv | |
http://www.fssprus.ru/opendata/7709576929-iplegallist/structure-20140318.csv | |
wget [url] -O [filepath] |