Skip to content

Instantly share code, notes, and snippets.

require("deepspeech");
@slaypni
slaypni / ! rllib_getting_started.py
Last active February 8, 2024 22:50
Simple code to use Ray Rllib with hyperparameter optimization
from datetime import datetime
from glob import glob
import os
from hyperopt import hp
from hyperopt.pyll.base import scope
import numpy as np
import ray
from ray import tune
from ray.rllib.agents.dqn import DQNAgent
@slaypni
slaypni / pmap.kt
Last active January 9, 2020 11:37
Parallel map for kotlin
import kotlinx.coroutines.experimental.async
import kotlin.coroutines.experimental.CoroutineContext
suspend fun <T, R> Iterable<T>.pmap(context: CoroutineContext, transform: suspend (T) -> R): List<R> {
return this.map {
async(context) {
transform(it)
}
}.map { it.await() }
}
@slaypni
slaypni / MLTest.java
Last active August 29, 2015 14:23
Machine Learning Sample Code with OpenCV 3.0 for Android
import android.util.Log;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.ml.LogisticRegression;
public class MLTest {
private final static String TAG = MLTest.class.getSimpleName();
MLTest() {
@slaypni
slaypni / xgb.py
Last active September 24, 2021 17:35
A wrapper class of XGBoost for scikit-learn
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import math
import numpy as np
sys.path.append('xgboost/wrapper/')
import xgboost as xgb
@slaypni
slaypni / iggts.coffee
Last active March 29, 2016 03:25
Download all photos posted by a user on Google+
#!/usr/bin/env coffee
API_KEY = 'Your API Key'
util = require 'util'
path = require 'path'
fs = require 'fs'
exec = (require 'child_process').exec
google = require 'googleapis'
cheerio = require 'cheerio'
@slaypni
slaypni / displayNSDataAsPlist
Created June 24, 2013 19:40
display NSArray / NSDictionary / NSData as plist format
- (void)displayNSDataAsPlist:(NSData*)data
{
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"temp.plist"];
[data writeToFile:path atomically:NO];
NSString* str = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSLog(@"%@", str);
}
@slaypni
slaypni / PBPopupBanner.java
Created October 2, 2012 07:45
A class for showing a view as pop-up [Android]
package com.example.utils;
import android.app.Activity;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
@slaypni
slaypni / gist:1333234
Created November 2, 2011 09:11
calculate Hubeny's distance from Geolocation
// http://yamadarake.web.fc2.com/trdi/2009/report000001.html
function calcHubenyDistance(lat1, lon1, lat2, lon2){
var a = 6378137.000;
var b = 6356752.314245;
var e2= 0.00669437999019758;
var y1 = lat1 * Math.PI / 180;
var x1 = lon1 * Math.PI / 180;
var y2 = lat2 * Math.PI / 180;
var x2 = lon2 * Math.PI / 180;