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
object scalaPractice { | |
def squareAddOne[T](x: T) | |
(implicit numeric: Numeric[T]): T = { | |
import numeric._ | |
x*x + one | |
} | |
squareAddOne(3) |
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 time | |
import threading | |
def sleep_print(n): | |
time.sleep(n) | |
print n | |
def thread_apply(func, item): | |
def run(): | |
func(item) |
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 local.john; | |
import java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileReader; | |
import java.io.InputStreamReader; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
import java.util.ArrayDeque; | |
import java.util.Iterator; |
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
#include <iostream> | |
#include <cmath> | |
#include <functional> | |
struct NewtonSolver { | |
std::function<float(const float)> f; | |
std::function<float(const float)> fprime; | |
const float tol; | |
NewtonSolver( | |
float(& arg_f)(const float), float(& arg_fprime)(const float), const float arg_tol): |
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 flask import Flask, render_template | |
from flask.ext.classy import FlaskView, route | |
# Instantiate the app: | |
app = Flask(__name__) | |
# create a metaclass to automatically register views with the app | |
# and create the class AutoregView to use it | |
# ------------------------------------------------------------------------------ | |
def Autoregistrant(app=app): |
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 flask | |
from flask.ext.classy import FlaskView, route | |
from functools import wraps | |
def charset_utf8(viewmethod): | |
# Let's update the 'Content-Type' in the HTTP header to tell the browser that the data we're | |
# responding with has utf-8 character encoding. | |
@wraps(viewmethod) | |
def new_viewmethod(*args, **kwargs): | |
resp = viewmethod(*args, **kwargs) |