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
//Microsoft Interview Question | |
function stricmp(a, b){ | |
var i = 0; | |
var aAscii, bAscii; | |
while(!isNaN(a.charCodeAt(i)) && !isNaN(b.charCodeAt(i))){ | |
aAscii = a.charCodeAt(i); | |
bAscii = b.charCodeAt(i); | |
i++; |
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
//Finds an unknown point distance L along a quadratic curve from a known point. | |
//Alex Pilafian 2017 - sikanrong@gmail.com - github.com/sikanrong | |
//If you reuse this code please give me attribution, my dude! I worked hard on this. | |
//parabola defined by ax^2 + bx + c, a and b are passed in to constructor while c is omitted because it isn't relevant to our calculations. | |
//u is known point x-value | |
//L is known length to travel down the curve for our unknown point. | |
//v is the unknown point x-value, once we have v we can calculate the correspondiing unknown y just by pluging it | |
//back into our parabola function |
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
//y = ax + c; reflection line | |
var reflected = {}; | |
var d = (point.x + (point.y - c)*a)/(1 + a^2); | |
reflected.x = 2*d - point.x; | |
reflected.y = 2*d*a - point.y + (2*c); |
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 untranslate = function(){ | |
var angle = Math.atan(slope); | |
var x1 = point.x - center.x; | |
var y1 = point.y - center.y; | |
var x2 = x1 * Math.cos(angle) - y1 * Math.sin(angle)); | |
var y2 = x1 * Math.sin(angle) + y1 * Math.cos(angle)); | |
var translated = {}; |
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
def get_balls | |
respond_to do |format| | |
response_obj = { :balls=>"sack" } | |
format.json { render :json => response_obj } # don't do response_obj.to_json | |
end | |
end |
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
{ | |
"cities": [ | |
{ | |
"name": "Madrid", | |
"Country": 1, | |
"lat": 40.429203, | |
"lng": -3.694986 | |
}, | |
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
zE(function(){$zopim(function(){ | |
$zopim.livechat.window.setOffsetHorizontal(100); | |
$zopim.livechat.window.setOffsetVertical(200); | |
});}); | |
zE(function(){$zopim(function() { | |
$zopim.livechat.setLanguage('sv'); | |
})}); | |
zE(function(){$zopim(function() { |
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
<html> | |
<body> | |
<script type="text/javascript"> | |
var newDiv = $('<div/>', { | |
id: 'elementID', | |
class: 'className' | |
}).appendTo('body'); | |
</script> | |
</body> | |
</html> |
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 animate = function(){ | |
var frameDuration = 1000; //milliseconds | |
var my = this; | |
setTimeout(function(){ | |
//do animate stuff here. Use "my" in place of "this" to access the outer object scope within the setTimeout function, if needed. | |
animate(); //re-calls itself. | |
}, frameDuration); | |
} |
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
scores = "Manchester United 1 Chelsea 0, Arsenal 1 Manchester United 1, Manchester United 3 Fulham 1, Liverpool 2 Manchester United 1, Swansea 2 Manchester United 4" | |
games_won = 0 | |
games_lost = 0 | |
games_drawn = 0 | |
goals_scored = 0 | |
goals_conceded = 0 | |
scores_array = scores.split(",") |