This file contains hidden or 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 Space from 'spaceace'; | |
const space = new Space({ | |
appName: "SpaceAce demoe", | |
user: { name: 'Jon', level: 9001 } | |
}); | |
const newSpace = space({ appName: "SpaceAce demo" }); | |
console.log(`Old app name: ${space.appName}, new app name: ${newSpace.appName}`); |
This file contains hidden or 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 React from 'react'; | |
import { string } from 'prop-types'; | |
class SegmentLoader extends React.Component { | |
componentDidMount() { | |
const { segmentWriteKey } = this.props; | |
// Create a queue, but don't obliterate an existing one! | |
const analytics = (window.analytics = window.analytics || []); | |
// If the real analytics.js is already on the page return. | |
// If no write key is provided return. |
This file contains hidden or 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
invalid_user = User.find_each.find(&:invalid?) |
This file contains hidden or 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
invalid_users = User.find_each.select { |user| user.invalid? } | |
# or | |
invalid_users = User.find_each.select(&:invalid?) |
This file contains hidden or 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
User.where('last_seen < ?', 2.months.ago).find_each do |user| | |
user.send_reminder! | |
end |
This file contains hidden or 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 oldIntl = window.Intl; | |
window.Intl = undefined; | |
var tzName = jstz.determine(); | |
window.Intl = oldIntl; |
This file contains hidden or 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
// Also works for normal methods | |
class User { | |
constructor (first, last) { | |
this.firstName = first; | |
this.lastName = last; | |
} | |
} | |
Object.defineProperty(User.prototype, 'name', { | |
get: function () { |
This file contains hidden or 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
(function () { | |
var ogJSONParse = JSON.parse; | |
JSON.parse = function (text, reviver) { | |
try { | |
return ogJSONParse(text, reviver); | |
} catch (err) { | |
console.error('Failed to parse: ', text); | |
console.error(err.stack); | |
return {}; |
This file contains hidden or 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 JonAbrams on github. | |
* I am jonabrams (https://keybase.io/jonabrams) on keybase. | |
* I have a public key whose fingerprint is 85C9 3D40 9117 7873 F035 F412 DD07 CC1A 9A43 AED2 | |
To claim this, I am signing this object: |
This file contains hidden or 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 Promise = require('bluebird'); // The best promise library out there | |
var request = require('request-promise'); // Scrapes the specified url, returns promise e.g. request(url) | |
var urls = process.argv.slice(2); // List of URLs to scrape | |
Promise.map(urls, request) // Returns an array of promises to the results of scraping the url | |
.each(console.log) // Call console.log on each resolved promise | |
.catch(console.error); |