This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var scrollticker; | |
jQuery(window).scroll(function() { | |
if (scrollticker) { | |
window.clearTimeout(scrollticker); | |
scrollticker = null; | |
} | |
// Set Timeout | |
scrollticker = window.setTimeout(function() { | |
if (jQuery('#div-fetching').length) { | |
if (jQuery(window).scrollTop() >= jQuery('#div-fetching').offset().top + jQuery('#div-fetching').outerHeight() - window.innerHeight) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'), | |
app = express(); | |
app.use( function(req, res, next) { | |
res.header('Access-Control-Allow-Origin', '*'); | |
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'); | |
res.header('Access-Control-Allow-Headers', 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept'); | |
next(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's lool at the following example structure for RESTful API using Node.js, Express.js included tesing | |
app/ | |
|---models/ | |
|---controller/ | |
|---helpers/ | |
|---middlewares/ | |
|---tests/ | |
|---models/ | |
|---controllers/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Constructor | |
function Foo(bar) { | |
// always initialize all instance properties | |
this.bar = bar; | |
this.baz = 'baz'; // default value | |
} | |
// class methods | |
Foo.prototype.fooBar = function() { | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scenario: Transferring money from current account to saving account | |
Given I have a current accout with 1000 | |
And I have a saving account with 2000 | |
When I transfer 500 from my current account to my savings account | |
Then I should have 500 in my current account | |
And I should have 2500 in my saving account |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code based on RFC 4122, section 4.4 (Algorithms for Creating a UUID from Truly Random or Pseudo-Random Number). | |
// http://www.ietf.org/rfc/rfc4122.txt | |
function createUUID() { | |
var s = []; | |
var hexDigits = "0123456789abcdef"; | |
for (var i = 0; i < 36; i++) { | |
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); | |
} | |
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010 | |
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $.get(url) | |
// .done(function(response) { | |
// if (response.status === 'success') { | |
// // draw chart line now | |
// //fnDrawChartPieAndBar(option); | |
// } else { | |
// console.log(response.message); | |
// } | |
// }).fail(function(error) { | |
// console.log(error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Logs | |
logs | |
*.log | |
npm-debug.log* | |
yarn-debug.log* | |
yarn-error.log* | |
# Runtime data | |
pids | |
*.pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The one-liner node.js http-proxy middleware for connect, express and browser-sync | |
https://github.com/chimurai/http-proxy-middleware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
export default class RenderProducts extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
innerWidth: window.innerWidth, | |
} | |
this.handleResize = this.handelResize.bind(this); | |
} | |
handleResize(){ |
OlderNewer