Skip to content

Instantly share code, notes, and snippets.

View alex9311's full-sized avatar
⛰️

Alex Simes alex9311

⛰️
View GitHub Profile
@alex9311
alex9311 / extjs_grid_exporter.md
Last active January 30, 2017 23:32
Sample function to download ExtJS grid data to CSV with filters, hidden columns

Exjts grids make it very easy to filter data, rearrange columns, hide/show columns, and many other things. The problem is that many grid download plugins go back to the store (database) to get the data. All the data modification that is happening on the client-side is not reflected in the download file.

Here is a hacked workaround that takes what is literally displayed on the grid and stuffs it in a CSV for the user. Probably not the most elegant or efficient implementation, but with my grid of ~800 rows and a dozen columns it still is instantaneous.

Credit to this gist and this SO post, which I combined and made a few modifications to to get this.

Further, some of the hardcoded values might need to be changed depending on your grid.

@alex9311
alex9311 / LDAspark.md
Last active April 15, 2020 23:13
How to implement LDA in Spark and get the topic distributions of new documents

How to implement LDA in Spark and get the topic distributions of new documents

import org.apache.spark.rdd._
import org.apache.spark.mllib.clustering.{LDA, DistributedLDAModel, LocalLDAModel}
import org.apache.spark.mllib.linalg.{Vector, Vectors}
import scala.collection.mutable

val stopWordsInput = sc.textFile("stopwords.csv")
val stopWords = stopWordsInput.collect()
@alex9311
alex9311 / PioMonit.md
Last active May 23, 2016 03:15
Monitoring PredictionIO with Monit

#Monitoring PredictionIO with Monit

If you're using PredictionIO in a production setting, you'll want some way to make sure it is always up. Monit is a tool which will monitor important processes and programs. This guide will show how to set up monit on your PredictionIO server to keep an engine always up and running.

##Install You can install monit on ubuntu with

sudo apt-get install monit
@alex9311
alex9311 / hive_to_csv.md
Last active October 25, 2016 16:29
bash script to convert segmented hive table to single csv

###Hive Default Delimiters to CSV #####Reasoning Hive's default delimiters are

Row Delimiter => Control-A ('\001')
Collection Item Delimiter => Control-B ('\002')
Map Key Delimiter => Control-C ('\003')
@alex9311
alex9311 / pio-cors-guide.md
Last active August 7, 2018 00:25
Enabling CORS on PredictionIO engine server

###Enabling CORS for a PredictionIO Engine This guide is meant for people who have no experience with nginx and want to enable Cross-Origin Resource Sharing (CORS) with their predictionIO instance. Enabling CORS is needed if you'd like to query your engine from anther domain's front end.

In my case, I had the recommender engine running on an aws instance. My goal was to query with AJAX from another domain. For example:

data = {'user': 'Bob', 'num': 4};
$.ajax({
    url: 'http://<pio ip>:8000/queries.json',
    type: 'POST',