Skip to content

Instantly share code, notes, and snippets.

@kevinylu
kevinylu / 0_reuse_code.js
Last active August 29, 2015 14:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kevinylu
kevinylu / javascript_resources.md
Last active August 29, 2015 14:14 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
@kevinylu
kevinylu / dateCount.js
Last active July 5, 2018 05:55
Javascript count total days between two date values
var startDate = new Date('Tue Jul 10 2018 00:00:00');
console.log('startDate:' + startDate);
var currentDate = new Date(new Date().setHours(0, 0, 0, 0));
console.log('currentDate:' + startDate);
var ONE_DAY = 1000 * 60 * 60 * 24;
var date1_ms = startDate.getTime();
var date2_ms = currentDate.getTime();
var difference_ms = Math.abs(date1_ms - date2_ms);
var dateCount = Math.round(difference_ms / ONE_DAY);
console.log('dateCount:' + dateCount);
@kevinylu
kevinylu / BaseController.swift
Created August 23, 2018 22:20 — forked from benbahrenburg/BaseController.swift
Adding Consistent Back Button to view
import UIKit
class BaseViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let backTitle = NSLocalizedString("Back", comment: "Back button label")
self.addBackbutton(backTitle)