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"; |
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
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 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
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 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
import numpy as np | |
def plot_correlation(dataframe, title='', corr_type=''): | |
lang_names = dataframe.columns.tolist() | |
tick_indices = np.arange(0.5, len(lang_names) + 0.5) | |
plt.figure(figsize=(12,7)) | |
plt.pcolor(dataframe.values, cmap='RdBu', vmin=-1, vmax=1) | |
colorbar = plt.colorbar() | |
colorbar.set_label(corr_type) | |
plt.title(title) |
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 sklearn.externals.six import StringIO | |
from sklearn import tree | |
from graphviz import Source | |
from IPython.display import SVG | |
def vizualize_tree(model, figsize=(14,8)): | |
out = StringIO() | |
tree.export_graphviz(model, out_file=out) | |
graph = Source(out.getvalue()) | |
graph.format = 'svg' |
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 matplotlib.pyplot as plt | |
from sklearn.svm import SVC | |
from sklearn.cross_validation import StratifiedKFold | |
from sklearn.feature_selection import RFECV | |
from sklearn.datasets import make_classification | |
# Create the RFE object and compute a cross-validated score. | |
svc = SVC(kernel='linear') | |
# The "accuracy" scoring is proportional to the number of correct | |
# classifications |
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
for bits in product([0, 1], repeat=4): | |
print("".join(str(b) for b in bits) |
OlderNewer