This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| QTimer* timer = new Qtimer(); | |
| connect(timer, SIGNAL(timeout(1)), thread, SLOT(threaCode)); | |
| // will get called every 1 milliseconds | |
| void threadCode() | |
| { | |
| timer->stop(); | |
| tryReceiveBytes(5, bytes); | |
| if(dead) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # run this command. | |
| # echo 'import script_data_pKwan' | python manage.py shell_plus | |
| import datetime | |
| from apps.franchises.models import Franchise | |
| from apps.orders.models import Order | |
| print "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| In [12]: class Base: | |
| 2 def __init__(self): | |
| 3 print("I'm base") | |
| 4 | |
| 5 class Child(Base): | |
| 6 def __init__(self): | |
| 7 print("I'm child") | |
| 8 | |
| In [13]: c = Child() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| // An example of function | |
| void someFunction(char * data) { | |
| int a; | |
| char * b; | |
| printf(data); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Person: | |
| def __init__(self, kargs, tup, *argv, **kwargs): | |
| import pdb; | |
| pdb.set_trace() | |
| self.name = kwargs['name'] | |
| self.shirt_size = kwargs['shirt_size'] | |
| def __str__(self): | |
| return "{} -> {}".format(self.name, self.shirt_size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime, timedelta | |
| import sys | |
| import os | |
| from flask import Flask | |
| from apscheduler.schedulers.background import BackgroundScheduler | |
| app = Flask(__name__) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def upload_file(request): | |
| if request.method == 'POST': | |
| form = NetworkScriptForm(request.POST, request.FILES) | |
| if form.is_valid(): | |
| content = request.FILES['file'].read() | |
| networkscript = NetworkScript.objects.create( | |
| title=request.POST['title'], | |
| script=content, | |
| ) | |
| return render(request, 'bod_detail.html', {'networkscript': networkscript}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| http://stackoverflow.com/a/5871851 |