Skip to content

Instantly share code, notes, and snippets.

@arsonus
arsonus / gist:5397d97340c6a5fb33027eb2c349e143
Created November 12, 2018 23:48 — forked from e1024kb/gist:41bf38fdb1a2cb19a781
Country - state list in JSON
{
"countries": [
{
"country": "Afghanistan",
"states": ["Badakhshan", "Badghis", "Baghlan", "Balkh", "Bamian", "Daykondi", "Farah", "Faryab", "Ghazni", "Ghowr", "Helmand", "Herat", "Jowzjan", "Kabul", "Kandahar", "Kapisa", "Khost", "Konar", "Kondoz", "Laghman", "Lowgar", "Nangarhar", "Nimruz", "Nurestan", "Oruzgan", "Paktia", "Paktika", "Panjshir", "Parvan", "Samangan", "Sar-e Pol", "Takhar", "Vardak", "Zabol"]
},
{
"country": "Albania",
"states": ["Berat", "Dibres", "Durres", "Elbasan", "Fier", "Gjirokastre", "Korce", "Kukes", "Lezhe", "Shkoder", "Tirane", "Vlore"]
},
@arsonus
arsonus / media-query.css
Created August 12, 2018 20:13 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@arsonus
arsonus / _magic-methods.md
Created June 9, 2018 01:54 — forked from loilo/magic-methods.js
PHP Magic Methods in JavaScript

JavaScript Magic Methods

This script implements some of PHP's magic methods for JavaScript classes, using a Proxy.

Example

You can use it like this:

const Foo = magicMethods(class Foo {
  constructor () {
    this.bar = 'Bar'
  }
@arsonus
arsonus / cross-browser-text-selection.js
Created February 6, 2018 22:02 — forked from jonathantneal/cross-browser-text-selection.js
cross-browser-text-selection.js
(function (win, doc) {
function getRangeAtCollapse(range, collapsed) {
// get range as item
if (range.item) {
var rangeItem = range.item(0);
// return the data
return { node: rangeItem };
}
// get range as text
var
@arsonus
arsonus / matchMedia.js
Created February 6, 2018 22:01 — forked from jonathantneal/matchMedia.js
Match Media
(function (window, screen, documentElement) {
/* ======================================================================
Setup
====================================================================== */
var hasEventListener = ('addEventListener' in window);
var hasOrientation = ('orientation' in window);
var hasGetComputedStyle = ('getComputedStyle' in window);
var regexpTrim = /^\s+|\s+$/g;
@arsonus
arsonus / Object.getClass.js
Created February 6, 2018 21:55 — forked from jonathantneal/Object.getClass.js
Object.getClass // returns the class name of an object
Object.getClass = function (object) {
return object === undefined ? "Undefined"
: object === null ? "Null"
: (String.toString.call(object.constructor || object).match(/\s\w+/) || [" Function"])[0].slice(1);
};
@arsonus
arsonus / vendorlessStyle.js
Created February 6, 2018 21:53 — forked from jonathantneal/vendorlessStyle.js
vendorlessStyle // allows DOM elements to support vendorless properties
this.CSSStyleDeclaration && function (CSSStyleDeclarationPrototype, defaultStyles, defaultProperty, specialProperty) {
for (defaultProperty in defaultStyles) {
specialProperty = defaultProperty.match(/^(O|Moz|ms|webkit)([A-Z])(.*)$/);
specialProperty && function (defaultProperty, genericProperty) {
Object.defineProperty(CSSStyleDeclarationPrototype, genericProperty, {
get: function () {
return this[defaultProperty];
},
set: function (value) {
@arsonus
arsonus / mimetypes.json
Created February 6, 2018 21:30 — forked from jonathantneal/mimetypes.json
Mime Types JSON
{
"audio/mp4": "m4a|f4a|f4b",
"audio/ogg": "oga|ogg",
"audio/&": "mid|midi|mp3|wav",
"application/javascript": "js|jsonp",
"application/json": "json",
"application/msword": "doc|dot",
"application/octet-stream": "bin",
"application/postscript": "ai",
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
@arsonus
arsonus / Image.prototype.barcode.js
Created February 6, 2018 21:28 — forked from jonathantneal/Image.prototype.barcode.js
Read barcodes from an image
// Image.prototype.barcode
(function () {
'use strict';
var UPC_SET = {
'3211': '0',
'2221': '1',
'2122': '2',
'1411': '3',
'1132': '4',
@arsonus
arsonus / README.md
Created February 6, 2018 21:26 — forked from jonathantneal/README.md
Parsing Social Media URLs

Parsing Social URLs

Match a variety of social media urls, detect their medium, and collect their single-most important ID.

{
	dailymotion: /https?:\/\/(?:www\.)?dailymotion\.com\/(swf|video)\/([^\/?&]+)/,
	googlemaps: /(^https?\:\/\/maps\.google\.com.+)/,
	googleplus: /https?:\/\/(?:plus\.google\.com|gplus\.to)\/([^\/?&]+)/,
	flickr: /https?:\/\/(?:www\.)?flickr\.com\/(?:people|photos)\/(\d+@N\d+)/,