Skip to content

Instantly share code, notes, and snippets.

Yevgeniy Brikman brikis98

Block or report user

Report or block brikis98

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
@brikis98
brikis98 / ClassDeclaration.js
Created Jun 12, 2011
JavaScript class declaration
View ClassDeclaration.js
function LinkedInClient(keys, tokens) {
// ...
};
LinkedInClient.prototype.getRequestToken = function(redirectUrl, callback) {
// ...
};
LinkedInClient.prototype.getAccessToken = function(oauthVerifier, callback) {
// ...
@brikis98
brikis98 / ClassDeclarationWithInheritance.js
Created Jun 12, 2011
JavaScript class declaration with inheritance
View ClassDeclarationWithInheritance.js
LinkedInClient.prototype = new BaseClient();
LinkedInClient.prototype.constructor = LinkedInClient;
function LinkedInClient(keys, tokens) {
// ...
};
LinkedInClient.prototype.getRequestToken = function(redirectUrl, callback) {
LinkedInClient.prototype.getRequestToken.call(this, redirectUrl, callback); // call method of "super" class
};
@brikis98
brikis98 / ClassDeclarationWithInheritance.coffee
Created Jun 12, 2011
CoffeeScript class declaration with Inheritance
View ClassDeclarationWithInheritance.coffee
class LinkedInClient extends BaseClient
constructor: (keys, tokens) ->
# ...
getRequestToken: (redirectUrl, callback) ->
super(redirectUrl, callback) # call method of "super" class
getAccessToken: (oauthVerifier, callback) ->
# ...
@brikis98
brikis98 / FunctionDeclaration.coffee
Created Jun 12, 2011
JavaScript vs. CoffeeScript function declaration
View FunctionDeclaration.coffee
getRequestToken = (redirectUrl, callback) ->
# Do something
@brikis98
brikis98 / SettingFields.coffee
Created Jun 12, 2011
JavaScript vs. CoffeeScript setting fields
View SettingFields.coffee
constructor: (@keys, @tokens) ->
# Do something else - this.keys and this.tokens are automatically set!
@brikis98
brikis98 / ThisAndCallbacks.js
Created Jun 12, 2011
JavaScript this keyword and callbacks
View ThisAndCallbacks.js
this.foo = 'bar';
console.log(this.foo); // prints 'bar'
$('#myButton').click(function(event) {
console.log(this.foo); // prints 'undefined' since it's not the same 'this'
});
@brikis98
brikis98 / ThisThatAndCallbacks.js
Created Jun 12, 2011
JavaScript this keyword, that, and callbacks
View ThisThatAndCallbacks.js
this.foo = 'bar';
console.log(this.foo); // prints 'bar'
var that = this; // save a reference
$('#myButton').click(function(event) {
console.log(this.foo); // prints 'undefined' since it's not the same 'this'
console.log(that.foo); // prints 'bar'
});
@brikis98
brikis98 / ThisBinding.coffee
Created Jun 12, 2011
CoffeeScript this binding
View ThisBinding.coffee
@foo = 'bar'
console.log(@foo) # prints 'bar'
$('#myButton').click (event) =>
console.log(@foo) # prints 'bar'
@brikis98
brikis98 / StringInterpolation.js
Created Jun 12, 2011
JavaScript's (lack of) string interpolation
View StringInterpolation.js
var url = LinkedInClient.baseUrl + "/v1/groups/" + id + "/posts:(" + LinkedInClient.groupFields.join(',') + ")?count=10";
this.oauth.getProtectedResource(url, 'GET', this.tokens.oauthAccessToken, this.tokens.oauthAccessTokenSecret, function(error, data, response) {
// ...
});
@brikis98
brikis98 / StringInterpolation.coffee
Created Jun 12, 2011
CoffeeScript string interpolation
View StringInterpolation.coffee
url = "#{LinkedInClient.baseUrl}/v1/groups/#{id}/posts:(#{LinkedInClient.groupFields.join(',')})?count=10"
@oauth.getProtectedResource url, 'GET', @tokens.oauthAccessToken, @tokens.oauthAccessTokenSecret, (error, data, response) =>
# ...
You can’t perform that action at this time.