Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

N37R06U3 n37r06u3

🏠
Working from home
  • Suzhou, China
Block or report user

Report or block n37r06u3

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@n37r06u3
n37r06u3 / gist:78eb88ea444822ee04ddf0574065d54e
Created Jun 30, 2017 — forked from pulse-/gist:8655893
Django migrate sqlite3 db to postgres - The easy way.
View gist:78eb88ea444822ee04ddf0574065d54e
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
View 流量统计.py
#!/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 Apr 8, 2017 — forked from MGinshe/odoo.conf
Sample Odoo/Nginx Config (with dbfilter_from_header support)
View odoo.conf
# 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 Apr 8, 2017 — forked from bistaray/odoo_install.sh
Install Odoo v10 Enterprise (with Bista repositories)
View odoo_install.sh
#!/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:
View gist:f0ecb94e76606505f8655c78da355b7b
<!DOCTYPE html>
<html>
<head>
<title>Angular HTML5 Preview, Crop And Upload</title>
<style>
body {
padding: 50px;
font: 16px Helvetica;
}
@n37r06u3
n37r06u3 / forms.py
Created Aug 24, 2016 — forked from oyakata/forms.py
djangoのRegexFieldの使用例
View forms.py
# -*- 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)
View PyTorStemPrivoxy.md

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 Aug 29, 2015
web server config(nginx + gunicorn+ django)
View gunicorn_conf.py
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"
View keyboardlistener.cs
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
{
View 400gb.user.js
// ==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() {
You can’t perform that action at this time.