Skip to content

Instantly share code, notes, and snippets.

View sumn2u's full-sized avatar
🌎

Suman Kunwar sumn2u

🌎
View GitHub Profile
@sumn2u
sumn2u / ajax
Created July 5, 2015 04:42
jquery validation with ajax example
<script type="text/javascript">
$('document').ready(function(){
$('#form').validate({
rules:{
"contact_name":{
required:true,
maxlength:40
},
"contact_email":{
@sumn2u
sumn2u / ajaxing
Created July 5, 2015 13:40
ajax example with XMLHttpRequest
var xRequest1;
if (window.XMLHttpRequest)
{
xRequest1 = new XMLHttpRequest();
} else {
xRequest1 = new ActiveXObject("Microsoft.XMLHTTP");
}
//Send the proper header information along with the request
@sumn2u
sumn2u / empty-collection
Created July 11, 2015 16:46
To remove all collections documents in MongoDB
db.getCollectionNames().forEach(function(c) {
if(!c.match("^system.indexes")) {
db.getCollection(c).remove({});
}
});
@sumn2u
sumn2u / select.js
Created September 17, 2015 13:30
Select in Ember
import Ember from 'ember';
export default Ember.Route.extend({
// campaigns: this.store.findAll('campaigns'),
model: function(){
return Ember.RSVP.hash({
campaigns: this.store.findAll('campaigns'),
leads: this.store.findAll('leads')
});
@sumn2u
sumn2u / infinte.js
Created September 23, 2015 05:56
Infinite scroll in Ember
import Ember from 'ember';
export default Ember.Route.extend({
lastThreadsPage: false,
limit: 25,
offset: 0,
model: function(){
var self = this;
return Ember.RSVP.hash({
ember new fuse-parakhi
cd fuse-parakhi
ember g http-mock project
ember serve --port 8080 --live-reload-port 35735
@sumn2u
sumn2u / database.js
Created January 10, 2016 04:42
connecting database
var mongoose = require('mongoose');
//setup the url for the connection
mongoose.connect('mongodb://localhost/list');
//create a connection
var db = mongoose.connection;
//if there is an error when logging in , print it
db.on('error', function(err){
console.log(err);
@sumn2u
sumn2u / database.js
Created January 10, 2016 04:42
connecting database
var mongoose = require('mongoose');
//setup the url for the connection
mongoose.connect('mongodb://localhost/list');
//create a connection
var db = mongoose.connection;
//if there is an error when logging in , print it
db.on('error', function(err){
console.log(err);
@sumn2u
sumn2u / package.json
Created January 10, 2016 04:43
package.json for REST API
{
"name": "application-name"
, "version": "0.0.1"
, "private": true
, "dependencies": {
"express": "2.5.8"
, "jade": ">= 0.0.1"
,"mongodb": "*"
,"mongoose": "*"
}