Skip to content

Instantly share code, notes, and snippets.

import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import cross_val_predict
from sklearn import metrics
import coremltools
dataset_url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data'
names = ['cultivar', 'alcohol', 'malic_acid', 'ash', 'alkalinity_ash', 'magnesium', 'total_phenols', 'flavonoids', 'nonflavonoid_phenols', 'proanthocyanins', 'color intensity', 'hue', 'od280_od315', 'proline']
@eh3rrera
eh3rrera / event-handler.js
Created March 29, 2017 18:37
Code for the event handler of a PubNub Block that returns the base64 representation of the QR code of an URL
/*
SAMPLE PAYLOAD
{
"url": "https://google.com"
}
*/
// https://gist.github.com/jonleighton/958841
const base64ArrayBuffer = function(arrayBuffer) {
var base64 = '';
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
import React, { useState } from 'react';
// ...
function App() {
if(1 !== 0) {
const [count, setCount] = useState(0);
}
return (
/* ... */
@eh3rrera
eh3rrera / publish.js
Created November 26, 2017 19:29
Node.js script to publish location and heading events to Pusher every two seconds
const Pusher = require('pusher');
const pusher = new Pusher({
appId: 'YOUR_PUSHER_APP_',
key: 'YOUR_PUSHER_APP_KEY',
secret: 'YOUR_PUSHER_APP_SECRET',
cluster: 'YOUR_PUSHER_APP_CLUSTER',
encrypted: true
});
@eh3rrera
eh3rrera / auth0-rule.js
Last active May 3, 2017 14:50
Auth0 rule to publish a signup/login event to Pusher
function (user, context, callback) {
var Pusher = require('pusher@1.2.1');
var pusher = new Pusher({
appId: '<INSERT_YOUR_PUSHER_APP_ID>',
key: '<INSERT_YOUR_PUSHER_APP_KEY>',
secret: '<INSERT_YOUR_PUSHER_APP_SECRET>',
cluster: '<INSERT_YOUR_PUSHER_APP_CLUSTER>',
encrypted: true
});
user.app_metadata = user.app_metadata || {};