This file contains 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
# Running in development, so use a local MySQL database. | |
DATABASES = { | |
'default': { | |
'ENGINE': 'google.appengine.ext.django.backends.rdbms', | |
'INSTANCE': 'gaeapp-001:blog', | |
'NAME': 'mysql', | |
'USER': 'root', | |
}, | |
'app-backend': { | |
'ENGINE': 'google.appengine.ext.django.backends.rdbms', |
This file contains 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
import json | |
from django.http import HttpResponse | |
from project.libs.pybcrypt import bcrypt | |
class ClassName: | |
def test(self): | |
json_response = json.dumps({"success": 1, "errors": 0, "msg": "test_successfully_sent"}) | |
return HttpResponse(json_response, mimetype="application/json") | |
def register(self, c, json_data): |
This file contains 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
""" | |
Here is the JSON structure the api is expecting | |
{ | |
"tag":"test", // or whatever the tag should be | |
"data": | |
{" | |
first_name":"firstname", | |
"last_name":"lastname", | |
"email":"email@email.com", |
This file contains 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 browser import document, ajax | |
#Ajax arguments | |
qs = '' | |
url = 'http://headers.jsontest.com/' | |
def post_data(url, qs): | |
req = ajax.ajax() | |
# Bind the complete State to the on_post_complete function | |
req.bind('complete',on_post_complete) | |
# send a POST request to the url |
This file contains 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
# Copy just lines 7 and 8 into the Brython online editor to try it out. | |
# Copy all of this code into a browser to try it on your own machine | |
<script src="{{ STATIC_URL }}js/brython/brython.js" type="text/javascript"></script> | |
<body onload="brython()"> | |
<script type="text/python"> | |
from browser import document | |
document['main'] <= "Hello world !" | |
</script> |
This file contains 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
import 'dart:html'; | |
import 'dart:math'; | |
void main() { | |
var rand = new Random(); | |
var randomIcon = querySelector('#randomIcon'); | |
if (rand.nextBool()){ | |
randomIcon.attributes['class'] = 'fa fa-android'; | |
}else{ |
This file contains 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
_IP=$(hostname -I) | |
# Make device discoverable | |
hciconfig hci0 piscan | |
# Set device name | |
hciconfig hci0 name 'My IP is '"$_IP" | |
# Wait 30 seconds | |
sleep 30 |
This file contains 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 timer(f): | |
""" | |
Decorator to time the execution of a function | |
:param f: The function to be timed | |
:return: The time in seconds that it took for the function to execute | |
""" | |
def timing_function(): | |
ts = time() | |
f() | |
te = time() |
This file contains 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
package com.example.webview.hellloworld; | |
import android.app.Activity; | |
import android.app.ProgressDialog; | |
import android.os.Bundle; | |
import android.view.Window; | |
import android.webkit.WebChromeClient; | |
import android.webkit.WebView; | |
import android.webkit.WebViewClient; |
This file contains 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
/* | |
* This class is a simple example showing a real world example of using AsyncTask to run a Network Thread. | |
* Nonrelevant is cut out in order to highlight the stucture of this class. | |
*/ | |
public class PlayNowActivity extends Activity { | |
RelativeLayout btnNewGame, btnLoad; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { |
NewerOlder