Skip to content

Instantly share code, notes, and snippets.

View n37r06u3's full-sized avatar
🏠
Working from home

N37R09U3 n37r06u3

🏠
Working from home
  • China
View GitHub Profile
@n37r06u3
n37r06u3 / gist:78eb88ea444822ee04ddf0574065d54e
Created June 30, 2017 07:54 — forked from pulse-/gist:8655893
Django migrate sqlite3 db to postgres - The easy way.
I had this really small problem today. I wanted to migrate one of my small django apps to use postgres, just to make everything easy to manage. Sqlite3 is perfectly fine for the amount of load, however I am really much faster at administering postgres than I am on sqlite3. So I decided to migrate the stuff over.
I tried a few approaches, but what ultimately worked the best and the fastest fo rmy particular problem was to do the following.
Use original SQLITE3 connection in settings.py
1. python manage.py dumpdata > dump.json
(I read some things here about some options you can pass, at the end what just worked was the following)
2. Change DB connection string in settings.py to POSTGRES
#!/usr/bin/python
# -*- coding: utf-8 -*-
# utf-8 中文编码
import glob
import os,sys
import json
reload(sys)
sys.setdefaultencoding('utf-8')
import time, sys,iptc # iptc 包通过 sudo pip install python-iptables 安装
from datetime import datetime
@n37r06u3
n37r06u3 / odoo.conf
Created April 8, 2017 16:00 — forked from ryanc-me/odoo.conf
Sample Odoo/Nginx Config (with dbfilter_from_header support)
# Author: Ryan Cole
# Website: https://ryanc.me
# GitHub: https://github.com/MGinshe
# Usage:
# Place this file in /etc/nginx/sites-enabled/
# Make sure you edit the DOMAIN_HERE and SSL_CERTIFICATE, and DB_FILTER sections
#
# Note: This config file is designed to be used with the Odoo dbfilter_from_header module
# https://apps.openerp.com/apps/modules/9.0/dbfilter_from_header/
@n37r06u3
n37r06u3 / odoo_install.sh
Created April 8, 2017 15:08 — forked from bistaray/odoo_install.sh
Install Odoo v10 Enterprise (with Bista repositories)
#!/bin/bash
################################################################################
# Script for installing Odoo V10 on Ubuntu 16.04, 15.04, 14.04
# Author: Yenthe Van Ginneken
# Adjusted: Ray Carnes
# Assumes you already have an Ubuntu user called "odoo" with a home folder
#-------------------------------------------------------------------------------
# Make a new file:
# sudo nano odoo-install.sh
# Place this content in it and then make the file executable:
<!DOCTYPE html>
<html>
<head>
<title>Angular HTML5 Preview, Crop And Upload</title>
<style>
body {
padding: 50px;
font: 16px Helvetica;
}
@n37r06u3
n37r06u3 / forms.py
Created August 24, 2016 12:39 — forked from oyakata/forms.py
djangoのRegexFieldの使用例
# -*- coding:utf-8 -*-
import re
from django import forms
USERID_REGEX = re.compile(r"^[\w-]+$")
class UserForm(forms.Form):
userid = forms.RegexField(max_length=64, regex=USERID_REGEX)

Crawling Anonymously with Tor in Python

adapted from the article "Crawling anonymously with Tor in Python" by S. Acharya, Nov 2, 2013.

The most common use-case is to be able to hide one's identity using TOR or being able to change identities programmatically, for example when you are crawling a website like Google and you don’t want to be rate-limited or blocked via IP address.

Tor

Install Tor.

@n37r06u3
n37r06u3 / gunicorn_conf.py
Last active August 29, 2015 14:18
web server config(nginx + gunicorn+ django)
import multiprocessing
import os
bind = "127.0.0.1:8080"
workers = multiprocessing.cpu_count()*2
worker_class = 'gevent'
timeout = 10000
daemon = True
pidfile = os.path.join(os.path.dirname(__file__), '..', 'log','gunicorn_server.pid')
errorlog = os.path.join(os.path.dirname(__file__), '..','log','gunicorn_server.log')
loglevel = "error"
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using System.Windows.Threading;
using System.Collections.Generic;
namespace Ownskit.Utils
{
// ==UserScript==
// @name 400gb.com Ads Remover
// @description Yes
// @version 0.1
// @author halfcoder
// @namespace http://github.com/halfcoder
// @include http://www.400gb.com/file/*
// ==/UserScript==
setTimeout(function() {