Skip to content

Instantly share code, notes, and snippets.

@jganzabal
jganzabal / Nvidia Titan XP + MacBook Pro + Akitio Node + Tensorflow + Keras.md
Last active November 2, 2022 11:43
How to setup Nvidia Titan XP for deep learning on a MacBook Pro with Akitio Node + Tensorflow + Keras
@danawoodman
danawoodman / 1-react-websockets-reflux.md
Last active September 15, 2021 14:48
Using WebSockets with Reflux and React

WebSockets + Reflux + React

Using WebSockets, React and Reflux together can be a beautiful thing, but the intial setup can be a bit of a pain. The below examples attempt to offer one (arguably enjoyable) way to use these tools together.

Overview

This trifect works well if you think of things like so:

  1. Reflux Store: The store fetches, updates and persists data. A store can be a list of items or a single item. Most of the times you reach for this.state in react should instead live within stores. Stores can listen to other stores as well as to events being fired.
  2. Reflux Actions: Actions are triggered by components when the component wants to change the state of the store. A store listens to actions and can listen to more than one set of actions.
@manfromanotherland
manfromanotherland / formspree.html
Last active July 30, 2021 07:05
JS: Ajax send forms using the most excellent Formspree » http://formspree.io #snippet
<form id="contact-form" action="//formspree.io/your@email.com" method="post">
<input type="text" name="Name" placeholder="Name" required>
<input type="email" name="Email" placeholder="Email" required>
<textarea name="Message" cols="30" rows="6" placeholder="Message" required></textarea>
<!-- CONFIG -->
<input class="is-hidden" type="text" name="_gotcha">
<input type="hidden" name="_subject" value="Subject">
<input type="hidden" name="_cc" value="email@cc.com">
<!-- /CONFIG -->
<input class="submit" type="submit" value="Send">
@ecarlson1201
ecarlson1201 / Shouter
Created August 24, 2018 01:03
String Drills
function shouter(whatToShout) {
return `${whatToShout.toUpperCase()}!!!`
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
function isDivisible(divisee, divisor) {
return Number.isInteger(divisee / divisor)
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
@ecarlson1201
ecarlson1201 / Catch Error
Created August 24, 2018 23:31
Control and Flow Drill
function main() {
try {
doAllTheThings()
} catch(e){
reportError(e)
console.dir(e)
}
}
function doAllTheThings() {
function accessFirstItem(array) {
const myArray = array
return myArray[0]
}
function accessThirdItem(array) {
const myArray = array
return myArray[2]
}
function minusLastItem(array) {
return array.slice(0, array.length-1)
}
function copyFirstHalf(array) {
return array.slice(0, array.length/2)
}
/* From here down, you are not expected to
understand.... for now :)
@ecarlson1201
ecarlson1201 / Find Average
Created August 26, 2018 10:31
Arrays and Loops Drills
function average(numbers) {
function getSum(total, num){
return (total + num)
}
return (numbers.reduce(getSum))/numbers.length
}
/* From here down, you are not expected to
understand.... for now :)
/* Scope is the idea of what can or cannot be seen in your code. Global scope encompasses code
that can be seen anywhere in your code, including other files and inside functions. Local scope
is code that can be accessed inside the current scope chain level. If you declare a variable inside
a function for instance, that variable will not be recognized outside that function. This allows for
less buggy code and the reuse of variable names.*/
/* Global variables are to be avoided because they increase the risk of writing buggy code. Functions that
rely on global variables can be both indeterminate and has side effects, meaning that the function may not
produce the same results given the same input and may also have unintended consequences outside the function
itself.*/