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
version: 2.0 | |
jobs: | |
test: | |
docker: | |
- image: circleci/node:8.10 | |
working_directory: ~/circleci-build | |
environment: | |
EXAMPLE_ENV_FOR_TESTING: "test" | |
steps: |
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
class Example extends React.Component { | |
componentDidMount () { | |
this.fetchData(this.props) | |
} | |
componentWillReceiveProps (props) { | |
if (props.id !== this.props.id) { | |
this.fetchData(props) | |
} | |
} |
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
// component A | |
const a = () => ( | |
<Overdrive id="bender-to-fry"> | |
<img src="bender.img"/> | |
</Overdrive> | |
); | |
// component B | |
const b = () => ( | |
<Overdrive id="bender-to-fry"> |
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 model = new Backbone.Model({counter: 1}); |
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
// Ok: | |
this.stateModel.on('change:readMore', this.renderReadMore, this); | |
// Awesome: | |
this.listenTo(this.stateModel, 'change:readMore', this.renderReadMore); |
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
@interface NSObject (Debounce) | |
- (void)debounce:(SEL)action delay:(NSTimeInterval)delay; | |
@end |
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 model (and any other model extending it) will be able to tell if it is synced with the server or not | |
var ChangeTrackableModel = Backbone.Model.extend({ | |
hasChangedSinceLastSync: false, | |
initialize: function() { | |
// If you extend this model, make sure to call this initialize method | |
// or add the following line to the extended model as well | |
this.listenTo(this, 'change', this.modelChanged); | |
}, |
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
// Boring | |
if (isThisAwesome) { | |
alert('yes'); // it's not | |
} | |
// Awesome | |
isThisAwesome && alert('yes'); | |
// Also cool for guarding your code | |
var aCoolFunction = undefined; |
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 inline_test = function(func, inputs, expected_outputs) { | |
for (var i in inputs) { | |
var input = inputs[i]; | |
var expected = expected_outputs[i]; | |
var result = func(input); | |
if (result != expected) { | |
console.log('Test failed! Expected', expected, 'but got', result); | |
// Or throw an error... | |
} | |
} |
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
NSString *command = @"ok glass, take a picture"; | |
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init]; | |
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:command]; | |
[synthesizer speakUtterance:utterance]; |
NewerOlder