Skip to content

Instantly share code, notes, and snippets.

View whats-new-create-react-app-3-01.js
import React, { useState } from 'react';
// ...
function App() {
if(1 !== 0) {
const [count, setCount] = useState(0);
}
return (
/* ... */
@eh3rrera
eh3rrera / publish.js
Created Nov 26, 2017
Node.js script to publish location and heading events to Pusher every two seconds
View publish.js
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
});
View wine_model.py
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 / auth0-rule.js
Last active May 3, 2017
Auth0 rule to publish a signup/login event to Pusher
View auth0-rule.js
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 || {};
@eh3rrera
eh3rrera / event-handler.js
Created Mar 29, 2017
Code for the event handler of a PubNub Block that returns the base64 representation of the QR code of an URL
View event-handler.js
/*
SAMPLE PAYLOAD
{
"url": "https://google.com"
}
*/
// https://gist.github.com/jonleighton/958841
const base64ArrayBuffer = function(arrayBuffer) {
var base64 = '';
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
You can’t perform that action at this time.