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
import timeit | |
normal_py_sec = timeit.timeit('sum(x*x for x in xrange(1000))', number=10000) | |
naive_np_sec = timeit.timeit('sum(na*na)', setup="import numpy as np; na=np.arange(1000)", number=10000) | |
good_np_sec = timeit.timeit('na.dot(na)', setup="import numpy as np; na=np.arange(1000)", number=10000) | |
print("Normal Python: %f sec" % normal_py_sec) | |
print("Naive NumPy: %f sec" % naive_np_sec) | |
print("Good NumPy: %f sec" % good_np_sec) |
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
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', '/media/resources/gamedev/weapon.json', true); | |
xhr.onload = function() { | |
JSON.parse(this.responseText); | |
}; | |
xhr.send(); |
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
import urllib2 | |
from bs4 import BeautifulSoup | |
import os | |
html_doc_example = """ | |
<html><head><title>ARST - Orari</title></head> | |
<div onclick="openClose('a1')" class="mainExpand"><h2><a style="cursor:pointer; src="pdfmini.jpg"/>ABBASANTA</h2></div> | |
<div id="a1" class="texter"> | |
<a href="402.pdf" target="_blank"><img src="pdfmini.jpg" />402 - ABBASANTA-GHILARZA-AIDOMAGGIORE-NORBELLO-ABBASANTA</a></br> |
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 base64 import b64encode | |
from PIL import Image, ImageDraw | |
import requests | |
from StringIO import StringIO | |
url = 'http://jssgallery.org/other_artists/andy_warhol/campbells.jpg' | |
response = requests.get(url) | |
img = Image.open(StringIO(response.content)) | |
draw = ImageDraw.Draw(img) |
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
import string | |
'!Hello,'.strip(string.punctuation) |
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
package com.example; | |
public FooBar { | |
@WiredMessage(mapping="BUTTONS-FOO") | |
private String foo = "foo"; | |
// clear selected button label | |
@WiredMessage(mapping="BUTTONS-BAR") | |
private String bar = "bar"; |
NewerOlder