Skip to content

Instantly share code, notes, and snippets.

View OElesin's full-sized avatar

Olalekan Fuad Elesin OElesin

View GitHub Profile
@timothyklim
timothyklim / ip.scala
Created August 3, 2012 21:34
IP to long and reverse on Scala
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
}
@benshimmin
benshimmin / gist:4088493
Created November 16, 2012 16:03
Scale to fit and centre-align an image with FPDF
<?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 {
@heldrida
heldrida / javascript
Last active March 11, 2024 17:00
Facebook Javascript SDK: Basic Login and Logout example
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: 'xxxxxxxxxxxxx',
status: true,
cookie: true,
xfbml: true
});
@debojitkakoti
debojitkakoti / seq_mongo_auto.php
Last active October 27, 2020 06:31
Auto Incrementing Sequence in mongodb using php mongo
<?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;
@escapeboy
escapeboy / codeigniter-rating-lib.php
Last active October 2, 2020 17:35
CodeIgniter Rating Library + Microdata (optional)
<?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 {
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@japsu
japsu / README.md
Last active February 9, 2022 21:34
ARCHIVED: How to get NumPy and SciPy working in a virtualenv under Mac OS X

ARCHIVED: How to get NumPy and SciPy working in a virtualenv under Mac OS X

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
@arnaldorusso
arnaldorusso / Help_arial_seaborn_tex.py
Created January 20, 2015 15:54
Help Arial font Seaborn using Tex
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)
@jkbradley
jkbradley / LDA_SparkDocs
Created March 24, 2015 23:56
LDA Example: Modeling topics in the Spark documentation
/*
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
@fancellu
fancellu / ConsumerExample.scala
Last active June 28, 2023 15:35
Kafka Producer/Consumer Example in Scala
import java.util
import org.apache.kafka.clients.consumer.KafkaConsumer
import scala.collection.JavaConverters._
object ConsumerExample extends App {
import java.util.Properties