Skip to content

Instantly share code, notes, and snippets.

Quick reference: Math

Data properties

  • Math.E: number ES1

    Euler’s number, base of the natural logarithms, approximately 2.7182818284590452354.

  • Math.LN10: number ES1

@ithinco
ithinco / string.md
Created February 20, 2019 23:30 — forked from rauschma/string.md

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

Array<T>

Legend:

  • ✏️ method changes this.
  • 🔒 method does not change this.

Array<T>.prototype.*:

  • concat(...items: Array: T[] 🔒 ES3
@ithinco
ithinco / gist:af99071713a7804bf23c
Last active August 29, 2015 14:02
Automatically switch vpns
set myVPNs to {"us1.vpnhide.com", "us2.vpnhide.com", "us3.vpnhide.com", "us4.vpnhide.com", "us5.vpnhide.com", "sg1.vpnhide.com", "sg2.vpnhide.com", "jp1.vpnhide.com", "jp2.vpnhide.com", "jp3.vpnhide.com", "tw1.vpnhide.com", "hk1.vpnhide.com", "hk2.vpnhide.com"}
set currentVPN to 0
set isPingLessThan400Count to 0
set vpn_name to "YUN (L2TP)"
set vpnExists to false
on vpn_status(vpn_name)
tell application "System Events"
return connected of configuration of service vpn_name of network preferences
end tell