Skip to content

Instantly share code, notes, and snippets.

//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++;
//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
//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);
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 = {};
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
{
"cities": [
{
"name": "Madrid",
"Country": 1,
"lat": 40.429203,
"lng": -3.694986
},
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() {
<html>
<body>
<script type="text/javascript">
var newDiv = $('<div/>', {
id: 'elementID',
class: 'className'
}).appendTo('body');
</script>
</body>
</html>
@sikanrong
sikanrong / animate.js
Last active August 29, 2015 14:22
javascript animate loop
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);
}
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(",")