Skip to content

Instantly share code, notes, and snippets.

😀
set your status

Oleg Gaidarenko markelog

😀
set your status
Block or report user

Report or block markelog

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
@markelog
markelog / gist:2390810
Created Apr 15, 2012
#8894 fix explanation
View gist:2390810
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
Copy in Firefox, Chrome and Safari
View gist:2589514
// 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
@markelog
markelog / gist:2706036
Created May 15, 2012
disconnected nodes and css
View gist:2706036
// suppose we have this in css
// .hidden { display: none; }
// .inline { display: inline; }
// then in javascrpit
$('<div class="hidden"/>').css("display");
// for FF – "none"
// for IE – "block"
// For Chrome, Opera – ""
@markelog
markelog / gist:3495987
Created Aug 28, 2012
#12346 – fn.append not working correctly
View gist:3495987
// In previous versions of jQuery, on every for iteration new div was created in jQuery.clean,
// now, on every iteration only one div is used, which created some problems –
// Illustration of WebKit bug
div = document.createElement("div");
div.innerHTML = "1";
nodes = jQuery.merge( [], div.childNodes );
div.innerHTML = "2";
View gist:5a5aec471886a863a136
// 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" )
View gist:7407ac01a054cdbf0cc5
$.xhr( "url", {
method: "post",
timeout: 1000,
});
// Same as
$.xhr( "url" ).method( "post" ).timeout( 1000 )
View gist:625fdec212b938b43738
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());
});
View gist:762c2584b53cace10fb3
file.iterateTokensByType("type", function() {
file === this // true
});
View gist:42d43a489afb7201ddd6
// 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 Oct 1, 2014
new approach to jscs config
View gist:bf9059f816d366c552c8
{
codeBlocks: {
curlyBraces: {
operators: true || [],
expect: [ "return", "break" ]
},
newlineBefore: {
statements: true,
expect: [ "for..of", "for" ]
You can’t perform that action at this time.