Skip to content

Instantly share code, notes, and snippets.

View markelog's full-sized avatar
😀
set your status

Oleg Gaidarenko markelog

😀
set your status
View GitHub Profile
// jQuery made popular chaining style in JavaScript,
// as i recall this approach we liked at San Diego meeting,
// i think we could use similar approach for $.xhr
//
// also https://github.com/visionmedia/superagent
$.xhr( "url" )
// Default method is GET
.method( "post" )
@markelog
markelog / gist:7407ac01a054cdbf0cc5
Created July 21, 2014 15:53
jQuery.xhr options
$.xhr( "url", {
method: "post",
timeout: 1000,
});
// Same as
$.xhr( "url" ).method( "post" ).timeout( 1000 )
it('should not require between simple arguments', function() {
assert(checker.checkString('foo(a,b);').getErrorCount() === 2);
assert(checker.checkString('foo( a,b);').getErrorCount() === 1);
assert(checker.checkString('foo( a,b );').isEmpty());
});
it('should not require spaces for empty arguments list', function() {
assert(checker.checkString('foo();').isEmpty());
});
@markelog
markelog / gist:762c2584b53cace10fb3
Created August 27, 2014 13:38
jscs, js-file, context
file.iterateTokensByType("type", function() {
file === this // true
});
@markelog
markelog / gist:42d43a489afb7201ddd6
Created September 28, 2014 12:17
More of jQuery.xhr
// See http://api.jquery.com/jQuery.ajax/#entry-examples
$.xhr( "some.php" )
.method( "POST" )
.send({ name: "John", location: "Boston" })
.then(function( xhr ) {
alert( "Data Saved:" + xhr.responseText );
});
$.xhr( "test.html" )
@markelog
markelog / gist:bf9059f816d366c552c8
Created October 1, 2014 18:39
new approach to jscs config
{
codeBlocks: {
curlyBraces: {
operators: true || [],
expect: [ "return", "break" ]
},
newlineBefore: {
statements: true,
expect: [ "for..of", "for" ]
@markelog
markelog / gist:752e53faf9f27de4024d
Last active August 29, 2015 14:07
new format for jscs
// Deprecate and remove:
/*
* (require | disallow)SpacesInFunctionExpression
* (require | disallow)requireSpacesInFunction
*/
{
options: {
additionalRules: [],
plugins: [],
fileExtensions: [],
{
configure: ...
getOptionName: ...
check: ...
format: /* global function for whitespace imported through `require` */
// or
format: /* string option "whitespace" which would signify what kind of manipulation should be done */
// or
format: /* "complicated" format function for hard to do rules */
@markelog
markelog / gist:2390810
Created April 15, 2012 07:55
#8894 fix explanation
var fragment, div, clonedNode, firstP, secondP, clonedP, dbi, clonedBdi,
node = document.createElement("div");
// true in all browsers
console.log( node.parentNode == null );
// but after
node.getElementsByTagName();
// true only in ie < 9
@markelog
markelog / gist:2589514
Created May 3, 2012 21:06
Copy in Firefox, Chrome and Safari
// We can't copy stuff in clipboard in Chrome, Safari and Firefox (Opera)
// Maybe one day this tickets will be resolved –
// https://bugzilla.mozilla.org/show_bug.cgi?id=407983
// https://bugs.webkit.org/show_bug.cgi?id=17645
// But if they will, we still can only copy text to clipboard only during clipboard events
// We might get around this, it's not a production code, just...
var clipboard = function() {};
// If we have firebug installed