(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
import collection.mutable.ListBuffer | |
object NetworkUtils { | |
def ip2Long(ip: String): Long = { | |
val atoms: Array[Long] = ip.split("\\.").map(java.lang.Long.parseLong(_)) | |
val result: Long = (3 to 0 by -1).foldLeft(0L)( | |
(result, position) => result | (atoms(3 - position) << position * 8)) | |
result & 0xFFFFFFFF | |
} |
<?php | |
/* Caveat: I'm not a PHP programmer, so this may or may | |
* not be the most idiomatic code... | |
* | |
* FPDF is a free PHP library for creating PDFs: | |
* http://www.fpdf.org/ | |
*/ | |
require("fpdf.php"); | |
class PDF extends FPDF { |
<div id="fb-root"></div> | |
<script> | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId: 'xxxxxxxxxxxxx', | |
status: true, | |
cookie: true, | |
xfbml: true | |
}); |
<?php | |
$m = new MongoClient(); | |
// select a database | |
$db = $m->seq; | |
// select a collection (analogous to a relational database's table) | |
$collection = $db->counters; | |
$user_collection = $db->user; | |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
/** | |
* Rating Library | |
* Using jQuery Raty plugin to rate products | |
* @author Nikola Katsarov | |
* @website http://katsarov.biz | |
*/ | |
class Rating { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Please don't use this method any more, this is ages old (2014, Python 2.7).
Assuming you use virtualenv
for Python library hygiene. Now you want Numpy and Scipy in your project.
NumPy and SciPy can not be easily installed under Mac OS X with a simple
pip install scipy
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib import rc | |
import seaborn as sns | |
# This line is a patch to Seaborn deal with mpl last version. | |
# sns.set_context(rc={'lines.markeredgewidth': 0.1}) # deal with mpl markers | |
xs = np.arange(200) |
/* | |
This example uses Scala. Please see the MLlib documentation for a Java example. | |
Try running this code in the Spark shell. It may produce different topics each time (since LDA includes some randomization), but it should give topics similar to those listed above. | |
This example is paired with a blog post on LDA in Spark: http://databricks.com/blog | |
Spark: http://spark.apache.org/ | |
*/ | |
import scala.collection.mutable |
import java.util | |
import org.apache.kafka.clients.consumer.KafkaConsumer | |
import scala.collection.JavaConverters._ | |
object ConsumerExample extends App { | |
import java.util.Properties |