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

Install virtualenv nginx, Supervisor, PostgreSQL, and uwsgi

I recommend the latest versions for Supervisor and uwsgi. I am using nginx 1.4.7 as that is the latest available on Gentoo (unmasked for ~amd64).

Gentoo

Unmask app-admin/supervisor and www-servers/uwsgi. In the case of x86-64:

app-admin/supervisor ~amd64
# Get and install logutils
# pip install logutils
# === settings.py ===
class PseudoTTY(object):
"""This allows a a fake tty which will allow PyCharm to always say its a tty"""
def __init__(self, underlying):
"""Define my underlying class"""

Use Django Fixtures to Automatically Load Data when You Install an App

First, load some data via the admin that should always be there when someone installs the app.

Next, dump that data out into JSON format into a fixture:

$ ./manage.py dumpdata [app_name] > [app_name]/fixtures/initial_data.json
// This is shamelessly copied from http://stackoverflow.com/questions/263743/how-to-get-cursor-position-in-textarea#answer-3373056
function getInputSelection(el) {
var start = 0, end = 0, normalizedValue, range, textInputRange, len, endRange;
if (typeof el.selectionStart == "number" && typeof el.selectionEnd == "number") {
start = el.selectionStart;
end = el.selectionEnd;
}
else {
range = document.selection.createRange();
if (range && range.parentElement() == el) {
// ==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() {
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
{

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 / 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)
@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:
#!/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