Skip to content
rows = export_order_csv(request.POST)
# nested method used only in this method to return a yield encoded data first the yield csv code later
def response_generator():
yield u'\ufeff'.encode('utf8')
for row in rows:
yield writer.writerow(row)
pseudo_buffer = Echo()
writer = csv.writer(pseudo_buffer)
View gist:89b742c610681dd024ca162390bfb240
from pyparsing import *
def plain_grammar():
return Word(printables + " ")
def command_grammar():
identifier = Word(alphas + '-_')
line_with_quotes = quotedString.setParseAction(removeQuotes)
plain_value = Word(alphanums + "-_")
View thread_exit.cpp
QTimer* timer = new Qtimer();
connect(timer, SIGNAL(timeout(1)), thread, SLOT(threaCode));
// will get called every 1 milliseconds
void threadCode()
tryReceiveBytes(5, bytes);
View gist:dcf83bbff15231200029f68ecb740d4e
# run this command.
# echo 'import script_data_pKwan' | python shell_plus
import datetime
from apps.franchises.models import Franchise
from apps.orders.models import Order
print ""
In [12]: class Base:
2 def __init__(self):
3 print("I'm base")
5 class Child(Base):
6 def __init__(self):
7 print("I'm child")
In [13]: c = Child()
View inheritance.cpp
#include <iostream>
// An example of function
void someFunction(char * data) {
int a;
char * b;
View gist:9f0296816e7df487eb4c672afac13965
class FranchiseUpdateView(viewsmixins.UpdateViewMixins):
model = Franchise
template_name = "franchise_update.html"
success_url = reverse_lazy('franchises:list')
form_class = FranchiseForm
form_prefix = "franchise"
# set prefix to parent form
def get_form_kwargs(self):
kwargs = super(FranchiseUpdateView, self).get_form_kwargs()
View gist:891c401a90ba39f326accef265b56f85
class Person:
def __init__(self, kargs, tup, *argv, **kwargs):
import pdb;
pdb.set_trace() = kwargs['name']
self.shirt_size = kwargs['shirt_size']
def __str__(self):
return "{} -> {}".format(, self.shirt_size)
View gist:d9aeb2f72e3fae45a21f4ca1584077a0
from flask import Flask, request
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class HelloWorld(Resource):
def post(self):
json = request.json
View gist:024808949b496f63d6d9306e840b71ca
from datetime import datetime, timedelta
import sys
import os
from flask import Flask
from apscheduler.schedulers.background import BackgroundScheduler
app = Flask(__name__)
Something went wrong with that request. Please try again.