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
// JSON.stringify({ date: new Date() }) --> '{"date":"2019-06-20T12:29:43.288Z"}' | |
// JSON.parse('{"date":"2019-06-20T12:29:43.288Z"}') --> { date: "2019-06-20T12:29:43.288Z" } | |
// hmm.. | |
// let's use the following function to revive our Date objects! | |
function jsonDateReviver(key, value) { | |
// plug this regex into regex101.com to understand how it works | |
// matches 2019-06-20T12:29:43.288Z (with milliseconds) and 2019-06-20T12:29:43Z (without milliseconds) | |
var dateFormat = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,}|)Z$/; | |
if (typeof value === "string" && dateFormat.test(value)) { |
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
/** | |
* Minimal Pub/Sub class | |
* | |
* @class EventEngine | |
*/ | |
class EventEngine { | |
/** | |
* Creates an instance of EventEngine. | |
* @memberof EventEngine | |
*/ |
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
// Modern method | |
// If you need to polyfill, see this MDN article https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from | |
var args = Array.from(arguments); | |
// Old school method | |
var args = [].slice.call(arguments); |
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
// POST example | |
var post = $.ajax({ | |
url: "/api/AttendancesAPI/AddOrEditMultiple", | |
type: "POST", | |
dataType: "json", | |
contentType: "application/json;charset=utf-8", | |
data: JSON.stringify({ | |
eventId: 1, | |
userAttendanceProxies: [ |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
namespace EventMate.Models | |
{ | |
/// <summary> | |
/// Proxy class that will be used facilitate populating or modifying multiple database rows | |
/// </summary> |
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
// Other using statements... | |
using Newtonsoft.Json.Linq; | |
// POST: api/AttendancesAPI/AddOrEditMultiple | |
[HttpPost, Route("api/AttendancesAPI/AddOrEditMultiple")] | |
[ActionName("AddOrEditMultiple")] | |
public HttpResponseMessage AddOrEditMultiple([FromBody]JToken attendanceProxy) | |
{ | |
// JToken as a parameter type allows us to accept JSON |
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
// webpack.config.js example | |
var OfflinePlugin = require('offline-plugin'); | |
module.exports = { | |
// ... | |
plugins: [ | |
// ... other plugins | |
// it's always better if OfflinePlugin is the last plugin added | |
new OfflinePlugin({ | |
ServiceWorker: { |
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
// ES2015 require | |
require('offline-plugin/runtime').install(); | |
// OR the new way which will require transpiling | |
import * as OfflinePluginRuntime from 'offline-plugin/runtime'; | |
OfflinePluginRuntime.install(); |
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
// webpack.config.js example | |
var OfflinePlugin = require('offline-plugin'); | |
module.exports = { | |
// ... | |
plugins: [ | |
// ... other plugins | |
// it's always better if OfflinePlugin is the last plugin added |
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 ... | |
app.use("/poketype/", express.static(path.join(__dirname, "../poketype/dist/"))) | |
// ... code ... |
NewerOlder