Skip to content

Instantly share code, notes, and snippets.

View evanportwood's full-sized avatar

Evan Portwood evanportwood

View GitHub Profile
@evanportwood
evanportwood / gist:1229889
Created September 20, 2011 18:28
compare date values
var expired = false;
if (new Date("4/5/2008 12:00:00 AM") < new Date()) {
expired = true;
}
alert(expired);
@evanportwood
evanportwood / gist:3656091
Created September 6, 2012 13:09 — forked from jheath/gist:3642286
RegEx replace with lowercased value

if you have a string like "6FA34323-C71F-4FD4-996F-002CE77E6B77"

search w/ regexp using ("[A-Z0-9-]+") replace with \L$1

\U will uppercase


Vim version:

@evanportwood
evanportwood / jquery.xdr.js
Created October 8, 2013 18:40
create xdr request of cors is not supported
if (!jQuery.support.cors && window.XDomainRequest) {
var httpRegEx = /^https?:\/\//i,
getOrPostRegEx = /^get|post$/i,
sameSchemeRegEx = RegExp("^" + location.protocol, "i"),
xmlRegEx = /\/xml/i;
jQuery.ajaxTransport("text html xml json", function (e, t) {
if (e.crossDomain && e.async && getOrPostRegEx.test(e.type) && httpRegEx.test(t.url) && sameSchemeRegEx.test(t.url)) {
var n = null,
i = (t.dataType || "").toLowerCase();
return {
.hide {
display: none;
}
#lnkNew {
font-size: .85em;
font-weight: normal;
margin-left: 1em;
}
@evanportwood
evanportwood / config.json
Created March 22, 2016 19:13 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "#3d8e33",
"@brand-success": "#5cb85c",
@evanportwood
evanportwood / README.md
Created March 22, 2016 21:08 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@evanportwood
evanportwood / tasks.json
Created September 23, 2016 14:50
VS Code tasks.json example to run msbuild and gulp tasks
{
"version": "0.1.0",
"command": "cmd",
"isShellCommand": true,
"args": ["/C"],
"tasks": [
{
"taskName": "Build Solution",
"suppressTaskName": true,
"isBuildCommand": true, // triggered via Ctrl+Shift+b
@evanportwood
evanportwood / viewport-units-ios.less
Created October 20, 2016 19:28 — forked from ziadkh0/viewport-units-ios.less
LESS mixin to support vh and vw units on all iOS Safari versions. Based on an idea by Patrick Burtchaell's: https://gist.github.com/pburtchaell/e702f441ba9b3f76f587 and the SCSS version by Benjamin Morel's: https://gist.github.com/BenMorel/e9e34c08360ebbbd0634
/**
* Fix for vw, vh, vmin, vmax on iOS 7.
* http://caniuse.com/#feat=viewport-units
*
* This fix works by replacing viewport units with px values on known screen sizes.
*
* iPhone 6 and 6 Plus cannot run iOS 7, so are not targeted by this fix.
* Target devices running iOS 8+ will incidentally execute the media query,
* but this will still produce the expected result; so this is not a problem.
*

#split string into an array of strings

source: http://stackoverflow.com/a/3008775/105282

namespace StringChunks
{
    static class Tools
    {
        public static IEnumerable<string> SplitByLength(this string str, int maxLength)