This file contains hidden or 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
| // | |
| // Regular Expression for URL validation | |
| // | |
| // Author: Diego Perini | |
| // Updated: 2010/12/05 | |
| // License: MIT | |
| // | |
| // Copyright (c) 2010-2013 Diego Perini (http://www.iport.it) | |
| // | |
| // Permission is hereby granted, free of charge, to any person |
This file contains hidden or 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
| require 'fileutils' | |
| directory = './files' | |
| new_directory = './new' | |
| files = Dir["#{directory}/*"] | |
| Dir.mkdir(new_directory) if !Dir.exists?(new_directory) | |
| files.each do |file| | |
| file_name = File.basename(file) | |
| directory_name = File.basename(file_name, File.extname(file_name)) | |
| directory_path = "#{new_directory}/#{directory_name}" |
This file contains hidden or 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
| ;(function() { | |
| // Used to resolve the internal `[[Class]]` of values | |
| var toString = Object.prototype.toString; | |
| // Used to resolve the decompiled source of functions | |
| var fnToString = Function.prototype.toString; | |
| // Used to detect host constructors (Safari > 4; really typed array specific) | |
| var reHostCtor = /^\[object .+?Constructor\]$/; |
This file contains hidden or 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 sheet = (function() { | |
| // Create the <style> tag | |
| var style = document.createElement('style'); | |
| // Add a media (and/or media query) here if you'd like! | |
| // style.setAttribute('media', 'screen') | |
| // style.setAttribute('media', 'only screen and (max-width : 1024px)') | |
| // WebKit hack :( | |
| style.appendChild(document.createTextNode('')); |
This file contains hidden or 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 indexOf = function(needle) { | |
| if(typeof Array.prototype.indexOf === 'function') { | |
| indexOf = Array.prototype.indexOf; | |
| } else { | |
| indexOf = function(needle) { | |
| var i = -1, | |
| index = -1; | |
| for(i = 0; i < this.length; i++) { | |
| if(this[i] === needle) { | |
| index = i; |
This file contains hidden or 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 images = document.querySelectorAll('img[data-src]'), | |
| imageLength = images.length; | |
| Array.prototype.forEach.call(images, function(image) { | |
| image.setAttribute('src', image.getAttribute('data-src')); | |
| image.onload = function() { | |
| image.removeAttribute('data-src'); | |
| }; | |
| }); |
This file contains hidden or 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
| function MyError(code, msg) { | |
| this.message = msg; | |
| this.statusCode = code; | |
| this.name = 'HttpError'; | |
| const err = Error(msg); | |
| this.stack = err.stack; | |
| } | |
| MyError.prototype = Object.create(Error.prototype); | |
| MyError.prototype.constructor = MyError; |
This file contains hidden or 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
| class ApplicationController | |
| before_filter :redirect_if_old | |
| # before_action :redirect_if_old # if Rails 4+ | |
| protected | |
| def redirect_if_old | |
| if request.host == 'old.com' | |
| redirect_to "#{request.protocol}new.io#{request.fullpath}", :status => :moved_permanently | |
| end |
This file contains hidden or 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
| Error.custromConstructor = (function() { | |
| function define(obj, prop, value) { | |
| Object.defineProperty(obj, prop, { | |
| value: value, | |
| configurable: true, | |
| enumerable: false, | |
| writable: true | |
| }); | |
| } |
This file contains hidden or 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
| (function (factory) { | |
| if (typeof define === "function" && define.amd) { | |
| define( ["jquery"], factory ); | |
| } else { | |
| factory( window.jQuery ); | |
| } | |
| }(function ($) { | |
| })); |