Skip to content

Instantly share code, notes, and snippets.

View wwj718's full-sized avatar

wwj718

View GitHub Profile
#coding:utf-8
#django test 中模拟登录的request
from django.contrib.sessions.middleware import SessionMiddleware
from django.test.client import RequestFactory
def add_session_to_request(request):
"""Annotate a request object with a session"""
middleware = SessionMiddleware()
@wwj718
wwj718 / grab-sessionid.py
Last active September 21, 2015 09:19 — forked from cgoldberg/grab-sessionid.py
grab session id from edX cookie
def login(email, password, base_url='https://courses.edx.org'):
"""Login via HTTP and parse sessionid from the cookie."""
r = requests.get('{}/login'.format(base_url))
csrf = r.cookies['csrftoken']
payload = {'email': email, 'password': password}
cookies = {'csrftoken': csrf}
headers = {'referer': '{}/login'.format(base_url), 'X-CSRFToken': csrf}
r = requests.post('{}/user_api/v1/account/login_session/'.format(base_url),
data=payload, cookies=cookies, headers=headers)
try:
@wwj718
wwj718 / missing_profiles.py
Last active September 21, 2015 09:21 — forked from bdero/missing_profiles.py
edX: Get users without student profiles
from django.contrib.auth.models import User
from student.models import UserProfile
profileless = [user for user in User.objects.all() if not UserProfile.objects.filter(user=user).count()]
@wwj718
wwj718 / gist:83c796b7211547c915ed
Last active September 21, 2015 09:28 — forked from antoviaque/gist:8423488
Granting superuser privileges to an existing user in edX
edxapp@edx:~/edx-platform$ ./manage.py lms shell --settings=devstack
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
@wwj718
wwj718 / gist:042686dbff114de11e48
Last active September 21, 2015 09:30 — forked from name1984/gist:2f6aa9f1c95673c027fd
configuracion microsites /edx/app/edxapp/lms.env.json
"FEATURES": {
"USE_MICROSITES": true
},
"MICROSITE_CONFIGURATION": {
"mineduc": {
"domain_prefix": "mineduc",
"university": "mineduc-forma",
"platform_name": "FormaX",
"logo_image_url": "mineduc/images/header-logo.png",
"email_from_address": "info@formax.edu.ec",
@wwj718
wwj718 / gist:c71a5fea975de4e54fde
Last active September 21, 2015 09:32 — forked from antoviaque/gist:945bae6ce259ac77fafe
Getting real user ids from anonymous_student_id in edX/LMS
mysql> select * from mentoring_answer ORDER BY id DESC LIMIT 1;
+-----+------+----------------------------------+---------------+---------------------+---------------------+---------------------------+
| id | name | student_id | student_input | created_on | modified_on | course_id |
+-----+------+----------------------------------+---------------+---------------------+---------------------+---------------------------+
| 285 | goal | 949b5f1c92d026420c75a83a8021a78a | fdsgsdg | 2014-10-14 19:06:41 | 2014-10-14 19:06:44 | slashes:Asses+A10+2014_A1 |
+-----+------+----------------------------------+---------------+---------------------+---------------------+---------------------------+
1 row in set (0.00 sec)
mysql> Bye
@wwj718
wwj718 / gist:b3a72e03a63b000c4b0c
Created November 5, 2015 05:53 — forked from jubos/gist:2409369
s3cmd config for Fake S3
[default]
access_key = asf
bucket_location = US
cloudfront_host = cloudfront.amazonaws.com
cloudfront_resource = /2010-07-15/distribution
default_mime_type = binary/octet-stream
delete_removed = False
dry_run = False
encoding = UTF-8
encrypt = False
@wwj718
wwj718 / cx_oracle.md
Created July 11, 2016 09:02 — forked from kimus/cx_oracle.md
Installing python cx_oracle on Ubuntu

First of all, it just seems like doing anything with Oracle is obnoxiously painful for no good reason. It's the nature of the beast I suppose. cx_oracle is a python module that allows you to connect to an Oracle Database and issue queries, inserts, updates..usual jazz.

Linux

Step 1:

sudo apt-get install build-essential unzip python-dev libaio-dev

Step 2. Click here to download the appropriate zip files required for this. You'll need:

@wwj718
wwj718 / 词性标记.md
Created August 5, 2016 09:50 — forked from luw2007/词性标记.md
词性标记: 包含 ICTPOS3.0词性标记集、ICTCLAS 汉语词性标注集、jieba 字典中出现的词性、simhash 中可以忽略的部分词性

词的分类

  • 实词:名词、动词、形容词、状态词、区别词、数词、量词、代词
  • 虚词:副词、介词、连词、助词、拟声词、叹词。

ICTPOS3.0词性标记集

n 名词

nr 人名

@wwj718
wwj718 / client.py
Created March 24, 2017 11:37 — forked from marvin/client.py
simple python client/server socket binary stream
import socket
HOST = 'localhost'
PORT = 9876
ADDR = (HOST,PORT)
BUFSIZE = 4096
videofile = "videos/royalty-free_footage_wien_18_640x360.mp4"
bytes = open(videofile).read()