Skip to content

Instantly share code, notes, and snippets.

@dreadjr
dreadjr / loadModel.py
Created April 13, 2018 20:17 — forked from vgpena/loadModel.py
Basic text classification with Keras and TensorFlow
import json
import numpy as np
import keras
import keras.preprocessing.text as kpt
from keras.preprocessing.text import Tokenizer
from keras.models import model_from_json
# we're still going to use a Tokenizer here, but we don't need to fit it
tokenizer = Tokenizer(num_words=3000)
# for human-friendly printing
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
@dreadjr
dreadjr / LinkedIn_500_API_error.php
Created March 19, 2018 09:58 — forked from sunils34/LinkedIn_500_API_error.php
Description of API request that receives a Linkedin 500 (Internal service error).
//URL: https://api.linkedin.com/v1/people/~/shares
//Request params:
Array
(
[content] => Array
(
[submitted-url] => http://forestnation.com/
[title] => Imagine ForestNation
[submitted-image-url] => http://forestnationcdn.forestnation.netdna-cdn.com/wp-content/uploads/2013/05/FN-World-150.png
[description] => Imagine a world where everyone grows their own tree. You plant one We plant one - Imagine ForestNation.
@dreadjr
dreadjr / antd_sc_example.js
Created March 8, 2018 01:43 — forked from newswim/antd_sc_example.js
Wrapping Ant Design components with Styled Components
import { Link } from 'react-router-dom'
import { Badge, Col, Menu } from 'antd'
const StyledBadge = styled(Badge)`
.ant-badge-count {
background-color: #7ECBBF;
color: white;
box-shadow: 0 0 0 1px #d9d9d9 inset;
}
`
@dreadjr
dreadjr / rxjs-firebase-demo.js
Created November 28, 2017 19:59 — forked from deltaepsilon/rxjs-firebase-demo.js
Demo RxJs integration with Firebase
var Rx = require('rxjs');
var firebase = require('firebase');
firebase.initializeApp({
"databaseURL": "https://quiver-two.firebaseio.com",
"serviceAccount": "./service-account.json"
});
var ref = firebase.database().ref('rxjs-demo');
Rx.Observable.fromPromise(ref.remove())
.map(function () {
@dreadjr
dreadjr / promises_reduce.js
Created November 15, 2017 16:30 — forked from anvk/promises_reduce.js
Sequential execution of Promises using reduce()
function asyncFunc(e) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(e), e * 1000);
});
}
const arr = [1, 2, 3];
let final = [];
function workMyCollection(arr) {
@dreadjr
dreadjr / makeTemplate.js
Created September 22, 2017 19:01 — forked from malko/makeTemplate.js
dynamic es6 template string to template methods
//const tpl = makeTemplate('hello ${name}')
//const name = 'world';
//tpl({name});
const makeTemplate = (templateString) => {
return (templateData) => new Function(`{${Object.keys(templateData).join(',')}}`, 'return `' + templateString + '`')(templateData);
}
@dreadjr
dreadjr / pbcopy.js
Created July 20, 2017 16:46 — forked from mkremins/pbcopy.js
node.js: put text into OS X clipboard
function pbcopy(data) {
var proc = require('child_process').spawn('pbcopy');
proc.stdin.write(data);
proc.stdin.end();
}
var saveUser = function(user, cb) {
var ref = new Firebase("https://<your-firebase>.firebaseio.com");
var usersRef = ref.child('users');
usersRef.child('count').once('value', function(snap) {
var priority = snap.val() ? snap.val() : 0;
usersRef.child(user.uid).setWithPriority(user, priority, function() {
// on complete, update user count
usersRef.child('count').transaction(function (current_value) { return (current_value || 0) + 1; });
});
@dreadjr
dreadjr / UserCreateFirebase.js
Created July 5, 2017 22:06 — forked from codenamejason/UserCreateFirebase.js
Create user if does not exist already
function go() {
var userId = prompt('Username?', 'Guest');
var userData = { name: userId };
tryCreateUser(userId, userData);
}
var USERS_LOCATION = 'https://<Firebase URL>.com/users';
function userCreated(userId, success) {
if (!success) {