This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Required on in a Node.js environment | |
const fetch = require('isomorphic-fetch'); | |
async function getInfoFromServer() { | |
// WITHOUT ASYNC/AWAIT | |
// fetch('https://deckofcardsapi.com/api/deck/new/draw/?count=1') | |
// .then(response => { | |
// return response.json(); | |
// }).then(json => { | |
// console.log('I drew the card, the ' + json.cards[0].value + ' of ' + json.cards[0].suit ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am mrbenj on github. | |
* I am bouqsbjunya (https://keybase.io/bouqsbjunya) on keybase. | |
* I have a public key ASD7EulbPY4MMFXmJKZxwx8TS7Wx59HPh6rs4RGaZTjFNgo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getJSON } from './promise_example'; | |
function init() { | |
getJSON('my-url.com').then( data => { | |
// data, the first param of resolve(), contains | |
// the response data from the XHR request | |
console.log(data); | |
}).catch( error => { | |
// oh no, something went wrong! | |
// error is the first param of reject() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Libs included: | |
underscore lodash chai sinon sinon-chai mocha async request q bluebird jsdom | |
*/ | |
function makeMove(move, currentPosition) { | |
let newPosition = [...currentPosition]; | |
switch(move) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am mrbenj on github. | |
* I am mrbenj (https://keybase.io/mrbenj) on keybase. | |
* I have a public key ASDEXUOG5iULUVhLq520Vvz9wAbEklEw_UTTOcbUmVW4IAo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var path = require('path'); | |
var favicon = require('serve-favicon'); | |
var logger = require('morgan'); | |
var cookieParser = require('cookie-parser'); | |
var bodyParser = require('body-parser'); | |
var routes = require('./routes/index'); | |
var users = require('./routes/users'); | |
var hbs = require('hbs'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* USAGE: | |
* | |
* {{#compare 'firstArgument' '===' 'secondArgument'}} | |
* <h1>I get rendered if the condition above is true!</h1> | |
* {{/compare}} | |
* | |
* **/ | |
hbs.registerHelper('compare', function(left, operation, right, options) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the @Override getView() portion of the Adapter class - recycles views in order to create a faster | |
// and much more efficient UI. Boosts framerates from 15 FPS to 50 FPS due to savvy memory allocation. | |
private LayoutInflater mInflater; | |
private List<SomeObject> mList; | |
// Constructor for Adapter object | |
public nameOfAdapter(Context context, List<SomeObject> myListOfObjects) { | |
mInflater = LayoutInflater.from(context); | |
mList = myListOfObjects; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
originalImage = Bitmap.createScaledBitmap( | |
originalImage // Bitmap to resize | |
view.getWidth(), // new width | |
view.getHeight(), // new height | |
true); // Enable bilinear filtering |