Skip to content

Instantly share code, notes, and snippets.

View lucndm's full-sized avatar
🎯
Focusing

Nguyễn Đăng Minh Lực lucndm

🎯
Focusing
View GitHub Profile
@lucndm
lucndm / roundTime.py
Created March 24, 2016 09:23
Round Time With Python
# https://stackoverflow.com/questions/3463930/how-to-round-the-minute-of-a-datetime-object-python/10854034#10854034
def roundTime(dt=None, roundTo=60):
"""Round a datetime object to any time laps in seconds
dt : datetime.datetime object, default now.
roundTo : Closest number of seconds to round to, default 1 minute.
Author: Thierry Husson 2012 - Use it as you want but don't blame me.
"""
if dt == None : dt = datetime.datetime.now()
seconds = (dt - dt.min).seconds
@lucndm
lucndm / Http, Firewall
Last active January 7, 2016 02:46
Tắt mở firewall trên lunix, tạo http nhanh
Tạo Http nhanh để download file
python -m SimpleHTTPServer
Tắt firewall
iptables -F
Mở lại firewall
iptables-restore < /etc/sysconfig/iptables
@lucndm
lucndm / Test
Created January 6, 2016 10:34
Test
dasfwfaf
@lucndm
lucndm / 2saoVnSpider.py
Created December 25, 2015 06:24
Crawler 2sao.vn
# -*- coding: utf-8 -*-
import scrapy
from scrapy.contrib.linkextractors import LinkExtractor
from scrapy.contrib.spiders import CrawlSpider, Rule
from manga_scrapy.items import VideoItem
#2sao.vn
class SaoVnSpider(CrawlSpider):
name = '2saovn'
allowed_domains = ['2sao.vn']