Skip to content

Instantly share code, notes, and snippets.

Avatar

Anjana anjanaraveendra

View GitHub Profile
View Change box dimensions dynamically
<!DOCTYPE html>
<html>
<head>
<style>
#box {
width: 100px;
height: 100px;
border: 10px solid green;
padding: 25px;
margin: 25px;
View Sample Model and Controller
#SurveyController Class
class Api::V1::SurveysController < Api::V1::BaseController
before_action :set_survey, only: [:show, :questions]
def index
# Api to get all current user schedules for the current time
@schedules = @account.schedules.includes(:survey, survey_version: :departments).joins(:survey)
.where(surveys: { status: 1 }, completed_at: nil).where(ignore: false)
.where('schedules.start_time <= :time AND schedules.buffer_time >= :time', time: Time.current)
.order('schedules.start_time asc')
View floyd_triangle.js
<script>
var tempStr = "",prevNumber=1,i,depth=10;
for(i=0;i<depth;i++){
tempStr = "";j=0;
while(j<= i){
tempStr = tempStr + " " + prevNumber;
j++;
prevNumber++;
}
console.log(tempStr);
View factorial.js
<script>
var a = prompt("Enter");
var f = 1;
for (var c = 1; c <= a; ++c) f *= c;
alert(f);
</script>
View fibonacci.js
var i;
var fib = [];
fib[0] = 0;
fib[1] = 1;
for(i=2; i<=10; i++)
{
fib[i] = fib[i-2] + fib[i-1];
}
alert(fib);
View palindrome.js
<script>
var a = prompt("Enter Value");
b = a.toString();
rev = b.split("").reverse().join("");
if(a == rev)
{
alert("Palindrome");
}
else
{
View even_or_odd.js
<script>
var a=prompt("Enter a value");
if(a%2==0)
{
alert("Given number is even");
}
else {
alert("Give number is odd");
}
</script>
View strong_number.js
<script>
var a=prompt("Enter a value");
z=a;
e = d = 0;
while(z > 0)
{
e = z % 10;
d = d + fact(e);
z = parseInt(z/10);
}
View prime_number.js
<script>
var a=prompt("enter a value");
var count=0;
for(var i=2;i<a;i++)
{
if(a%i==0)
{
count=i;
}
View armstrong_number.js
<script>
var e,x,d=0;
var b=prompt("Enter a number");
x=b;
while(x>0)
{
e=x%10;
d=d+(e*e*e);
x=parseInt(x/10);
}