Skip to content

Instantly share code, notes, and snippets.

Tal Bereznitskey berzniz

Block or report user

Report or block berzniz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@berzniz
berzniz / config.yml
Created Jun 6, 2018
Starter CircleCI v2 configuration for Node.js apps
View config.yml
version: 2.0
jobs:
test:
docker:
- image: circleci/node:8.10
working_directory: ~/circleci-build
environment:
EXAMPLE_ENV_FOR_TESTING: "test"
steps:
@berzniz
berzniz / react.jsx
Last active Mar 28, 2018
Example for "Update on Async Rendering"
View react.jsx
class Example extends React.Component {
componentDidMount () {
this.fetchData(this.props)
}
componentWillReceiveProps (props) {
if (props.id !== this.props.id) {
this.fetchData(props)
}
}
View overdrive.jsx
// component A
const a = () => (
<Overdrive id="bender-to-fry">
<img src="bender.img"/>
</Overdrive>
);
// component B
const b = () => (
<Overdrive id="bender-to-fry">
@berzniz
berzniz / 1.js
Last active Aug 29, 2015 — forked from anonymous/1.js
View 1.js
var model = new Backbone.Model({counter: 1});
@berzniz
berzniz / bind-unbind.js
Last active Aug 29, 2015
Backbone tips & rules
View bind-unbind.js
// Ok:
this.stateModel.on('change:readMore', this.renderReadMore, this);
// Awesome:
this.listenTo(this.stateModel, 'change:readMore', this.renderReadMore);
@berzniz
berzniz / NSObject+Debounce.h
Created Jan 25, 2014
Debounce method for Objective C
View NSObject+Debounce.h
@interface NSObject (Debounce)
- (void)debounce:(SEL)action delay:(NSTimeInterval)delay;
@end
@berzniz
berzniz / ChangeTrackableModel.js
Last active Aug 24, 2017
A model that "knows" if it has unsaved changes
View ChangeTrackableModel.js
// 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);
},
@berzniz
berzniz / jshipster_and_and.js
Last active May 17, 2019
Some small javascript hacks for hipsters
View jshipster_and_and.js
// Boring
if (isThisAwesome) {
alert('yes'); // it's not
}
// Awesome
isThisAwesome && alert('yes');
// Also cool for guarding your code
var aCoolFunction = undefined;
View inline_test.js
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...
}
}
View siri_google_glass
NSString *command = @"ok glass, take a picture";
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:command];
[synthesizer speakUtterance:utterance];
You can’t perform that action at this time.