Skip to content

Instantly share code, notes, and snippets.

View OElesin's full-sized avatar

Olalekan Fuad Elesin OElesin

View GitHub Profile
@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)
@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
}
@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
@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 {
@jcbf
jcbf / lambda.py
Last active October 20, 2020 08:26
Make queries to Elasticsearch from a lambda in python
# Run get info from Elasticsearch from AWS Lambda.
from __future__ import print_function
import boto3
import certifi
import yaml
from aws_requests_auth.aws_auth import AWSRequestsAuth
from elasticsearch import Elasticsearch, RequestsHttpConnection
def handler(event, context):
@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;
@dasgoll
dasgoll / EMR_cluster.template
Created August 3, 2017 08:15
EMR cluster cloudformation template
{
"Conditions": {
"WithSpotPrice": {
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "SpotPrice"
},
"0"
@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

Generating Flame Graphs for Apache Spark

Flame graphs are a nifty debugging tool to determine where CPU time is being spent. Using the Java Flight recorder, you can do this for Java processes without adding significant runtime overhead.

When are flame graphs useful?

Shivaram Venkataraman and I have found these flame recordings to be useful for diagnosing coarse-grained performance problems. We started using them at the suggestion of Josh Rosen, who quickly made one for the Spark scheduler when we were talking to him about why the scheduler caps out at a throughput of a few thousand tasks per second. Josh generated a graph similar to the one below, which illustrates that a significant amount of time is spent in serialization (if you click in the top right hand corner and search for "serialize", you can see that 78.6% of the sampled CPU time was spent in serialization). We used this insight to spee

@srcecde
srcecde / Install ffmpeg & ffprobe on Amazon Linux
Created November 19, 2021 08:19
Install & configure ffmpeg, ffprobe on SageMaker (Amazon Linux)
cd /usr/local/bin
sudo mkdir ffmpeg && cd ffmpeg
# check https://johnvansickle.com/ffmpeg/ for latest build
sudo wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
sudo tar -xf ffmpeg-release-amd64-static.tar.xz
sudo ln -s /usr/local/bin/ffmpeg/ffmpeg-4.4.1-amd64-static/ffmpeg /usr/bin/ffmpeg
sudo ln -s /usr/local/bin/ffmpeg/ffmpeg-4.4.1-amd64-static/ffprobe /usr/bin/ffprobe