Skip to content

Instantly share code, notes, and snippets.

View qmaruf's full-sized avatar
🤖
Training robot

Quazi Marufur Rahman qmaruf

🤖
Training robot
View GitHub Profile
@qmaruf
qmaruf / gist:8694621
Last active August 29, 2015 13:55
Jasmine test failing
describe("display alert for unsaved publisher content", function(){
it('should display confirm dialog if text exists in status message', function(){
$('#status_message_fake_text').val('Hello world');
spyOn(window, 'confirm');
$(window).trigger('confirm')
expect(window.confirm).toHaveBeenCalled();
});
});
@qmaruf
qmaruf / gist:8717053
Last active August 29, 2015 13:55
Unsaved navigation alert
$(window).on('beforeunload unload', _.bind(_this._unsavedPublisherWarning, _this));
_unsavedPublisherWarning : function(){
var publisherTextLength = this.el_input.val().trim().length;
if(publisherTextLength){
return "navigation_warning";
}
}
@qmaruf
qmaruf / gist:8717089
Created January 30, 2014 19:38
jasmine test for unsaved redirection
describe("display alert for unsaved publisher content", function(){
it('should display confirm dialog if text exists in status message', function(){
$('#status_message_fake_text').val('Hello world');
spyOn(window, 'confirm');
$(window).trigger('beforeunload')
expect(window.confirm).toHaveBeenCalled();
});
});
line = " Hello World!! "
print line.strip() #remove empty spaces from start and end
print line.lstrip() #remove empty spaces from start
print line.rstrip() #remove empty spaces from end
mylist = ['apple', 'orange', 'mango']
print ', '.join(mylist)
mylist = [1, 2, 3]
print str(mylist).strip('[]')
mylist = ['1', '2', '3']
print [int(item) for item in mylist]
@qmaruf
qmaruf / gist:10957924
Created April 17, 2014 06:32
c++, pass by ref
// pass by ref example
#include <iostream>
using namespace std;
/*
store memory address using pointer type variable.
int* x : x is a variable to store memory address
of another variable.
*x : use this syntax to access value from memory address.
@qmaruf
qmaruf / gist:1e75e03957b9297c71b9
Last active August 29, 2015 14:00
neo4j, create sample db
#create db
create(a{n:"a"}),(b{n:"b"}),(c{n:"c"}),(d{n:"d"}),(e{n:"e"}),
a-[:parent_of]->b,
a-[:parent_of]->c,
b-[:parent_of]->d,
d-[:parent_of]->e,
e-[:parent_of]->c,
d-[:parent_of]->c;
#do query
@qmaruf
qmaruf / neo4j
Last active August 29, 2015 14:01
START n=node(*)
WHERE has (n.name)
and n.name="Google"
RETURN n
@qmaruf
qmaruf / neo4j
Created May 16, 2014 16:03
neo4j
#count node
START n=node(*)
RETURN count(n)
#count relationship
START r=relationship(*)
RETURN count(r)
#get all nodes
START n=node(*)
RETURN n;
#delete all nodes
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r