Skip to content

Instantly share code, notes, and snippets.

View DonerKebab's full-sized avatar
💀

Phuong Nguyen DonerKebab

💀
View GitHub Profile
@DonerKebab
DonerKebab / read_csv_benchmark.py
Created November 22, 2016 07:58
Fastest Python library to read a CSV file
import csv
import os
import cProfile
import time
import numpy
import pandas
import warnings
# Make sure those files in the same folder as benchmark_python.py
# As the name indicates:
@DonerKebab
DonerKebab / send_email.py
Last active November 24, 2016 04:07
a simplest way to send gmail
import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login("YOUR EMAIL ADDRESS", "YOUR PASSWORD")
msg = "YOUR MESSAGE!"
server.sendmail("YOUR EMAIL ADDRESS", "THE EMAIL ADDRESS TO SEND TO", msg)
server.quit()
@DonerKebab
DonerKebab / login.py
Created November 25, 2016 07:03
django: login remember me
def login(request, *args, **kwargs):
if request.method == 'POST':
if not request.POST.get('remember_me', None):
request.session.set_expiry(0)
return auth_views.login(request, *args, **kwargs)
@DonerKebab
DonerKebab / Useful celery config, commands
Created November 29, 2016 05:09
Useful celery config, commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
import unittest
class Game(object):
def __init__(self):
self.rolls = [0] * 21
self.currentRoll = 0
$ curl -L https://github.com/docker/compose/releases/download/1.12.0/docker-compose-`uname -s`-`uname -m` > ./docker-compose
$ sudo mv ./docker-compose /usr/bin/docker-compose
$ sudo chmod +x /usr/bin/docker-compose
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
sudo cp wkhtmltox/bin/wkhtmlto* /usr/bin/
@DonerKebab
DonerKebab / auto_publish_post_facbook.py
Created October 18, 2017 02:10
A script that auto scan from csv file row by row then publish post using row data
# csv format: content | link_to_website
import requests
import csv
import json
import time
PAGE_ID = 'your_facebook_page_id' # find page id : https://findmyfbid.com
ACCESS_TOKEN = 'your_app_access_token' # https://developers.facebook.com/tools/explorer
REQUEST_FORM = 'https://graph.facebook.com/PAGE_ID/feed?message=TITLE&link=PRODUCT_LINK'
@DonerKebab
DonerKebab / mixin.py
Created November 7, 2017 02:50 — forked from cyberdelia/mixin.py
Django class based view mixins
# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
from django.utils.cache import patch_response_headers
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page, never_cache
from django.views.decorators.csrf import csrf_exempt
class NeverCacheMixin(object):
@method_decorator(never_cache)
#FROM http://mikelynchgames.com/software-development/installing-oracle-instant-client-and-sqlplus-on-osx/
#REQUIRED
# instantclient-basic-macosx-<version>.zip
# instantclient-sdk-macosx-<version>.zip
# instantclient-sqlplus-macosx-<version>.zip
# put this script in the same folder as these downloaded