Skip to content

Instantly share code, notes, and snippets.

@bslima
bslima / gist:5321919
Created April 5, 2013 19:26
Scrapy django integration
def setup_django_env(path):
import imp, os
from django.core.management import setup_environ
f, filename, desc = imp.find_module('settings', [path])
project = imp.load_module('settings', f, filename, desc)
setup_environ(project)
setup_django_env('../django/viajala/')
spider_count = 0
# Get a signal that a crawler has finished its job, start another crawler
def spider_closed(spider, reason):
spider_count += 1
#Only starts another crawler if available
if spider_count < len(spiders):
reactor.callLater(0, start_crawler, spider=spiders[spider_count])
else:
@bslima
bslima / cancelar_venda.php
Created July 31, 2013 15:34
Cancelar venda cafufa
public static function cancelar_venda( $venda_id ) {
// ----------------------------
// Inicia uma MYSQL TRANSACTION
// ----------------------------
Venda::begin_transaction();
//pega a venda no banco
$venda = Venda::where_venda_id( $venda_id )->first();
@bslima
bslima / file_extesions.php
Created August 7, 2013 23:21
how to get the filename extesion
//nao precisa ser um arquivo no sistema
$ext = pathinfo($filename, PATHINFO_EXTENSION);
@bslima
bslima / laravel_redis.php
Created August 11, 2013 22:25
How to enable laravel 3.x redis connection to take password.
... ... @@ -17,6 +17,13 @@ class Redis {
17 17 protected $port;
18 18
19 19 /**
20 + * The password for connect to Redis.
21 + *
22 + * @var string
23 + */
24 + protected $password;