Skip to content

Instantly share code, notes, and snippets.

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
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 = {};
//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);
//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
//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++;
//Bitwise programming interview question
var isPowerOfFour = function(x){
var bitIdx = 0;
var currentIdx = 0;
var bitCount = 0;
while(x){
if(x & 1){
bitCount++;
//Smallest power of 2 greater than or equal to n
//https://www.geeksforgeeks.org/smallest-power-of-2-greater-than-or-equal-to-n/
var smallestPowerOfTwo = function(x){
var bitPlaces = 0;
while(x){
bitPlaces++;
x >>= 1;
}
return 1 << bitPlaces;
//https://www.geeksforgeeks.org/calculate-square-of-a-number-without-using-and-pow/
//Calculate a number's square without using /, *, or pow().
#include <stdio.h>
int main(){
int n;
printf("Please enter an integer: ");
//https://www.geeksforgeeks.org/rotate-bits-of-an-integer/
/*
* rotate_bits.c
*
* Created on: Aug 2, 2018
* Author: sikanrong
*/
#include <stdio.h>
//https://www.geeksforgeeks.org/check-if-a-given-number-is-sparse-or-not/
/*
* check_sparse.c
*
* Created on: Aug 2, 2018
* Author: sikanrong
*/