This file contains 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 Person = function(name) { | |
this.name = name; | |
} | |
Person.prototype.getName = function() { | |
return this.name; | |
} | |
var thomas = new Person("thomas") |
This file contains 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 Person = function(name) { | |
this.name = name; | |
} | |
Person.prototype.getName = function() { | |
return this.name; | |
} | |
var thomas = new Person("thomas") |
This file contains 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
// ah, wrap the function in parentheses! | |
Number.prototype.times = (function(theString) { | |
this.theString = theString; | |
var result = ""; | |
for (var i = 0; i< this; i++){ | |
result += this.theString; | |
} | |
//return this + " ; " + this.theString; | |
return result; |
This file contains 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
Number.prototype.isCreditCard = ( | |
function() { | |
var testCC = this.toString(); | |
var sum =0; mul = 1; l = testCC.length; | |
if (l < 19) { | |
for (i = 0; i < l; i++) | |
{ | |
var digit = testCC.substring(l-i-1,l-i); | |
var tproduct = parseInt(digit ,10)*mul; |
This file contains 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
<!-- 1. Change the addEventListener calls so that the events occur in the following order. | |
the_div! the_item! the_list! --> | |
<div id="the_div"> | |
<ul id="the_list"> | |
<li id="the_item">Click me!</li> | |
</ul> | |
</div> | |
<p id="log"></p> |
This file contains 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
img { | |
display: block; | |
} |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Page Refresher</title> | |
</head> | |
<body> | |
<h1>Page Refresher</h1> | |
<p>Drag the link below to your toolbar to install the "page refresher" bookmarklet. Press the bookmarklet and you will be prompted for when you'd like the page you're on to be refreshed in your browser.</p> | |
<a href="javascript: (function () { var jsCode = document.createElement('script'); jsCode.setAttribute('src', 'https://gist.githubusercontent.com/johnfmorton/9238562/raw/b2a65b62c17569d3d275b9f2a755d14658e8d036/pagerefresher.js'); document.body.appendChild(jsCode); }());">Refresher</a> |
This file contains 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
private func setBackgroundColor(redColor: Int, greenColor: Int, blueColor: Int) -> Bool{ | |
// colors should be from 0 to 255, like you get when picking colors in Photoshop | |
if redColor < 0 || greenColor < 0 || blueColor < 0 { | |
println("At least one color value not in range. Must be at least 0") | |
return false | |
} | |
if redColor > 255 || greenColor > 255 || blueColor > 255 { | |
println("At least one color value not in range. Must be at less than 255") | |
return false | |
} |
This file contains 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
// returns true is browser is mobile | |
// added "|android|ipad|playbook|silk" to first regex to detect tablets | |
// This leaves 2 'android' tests in the first regex. One of the 'android' tests can be eliminated | |
// but left in so you can remove the "|android|ipad|playbook|silk" string easily. | |
function isMobile() { | |
var a = navigator.userAgent||navigator.vendor||window.opera; | |
if (/(android|bb\d+|meego|android|ipad|playbook|silk).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng) |
This file contains 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
// -- I didn't make this but it's really handy! - John | |
/// Convert angle | |
/// @author Chris Eppstein | |
/// @param {Number} $value - Value to convert | |
/// @param {String} $unit - Unit to convert to | |
/// @return {Number} Converted angle | |
@function convert-angle($value, $unit) { | |
$convertable-units: deg grad turn rad; | |
$conversion-factors: 1 (10grad/9deg) (1turn/360deg) (3.1415926rad/180deg); |
OlderNewer