Skip to content

Instantly share code, notes, and snippets.

View sushant12's full-sized avatar
๐Ÿ˜Ž
Focusing

Suss Buzz sushant12

๐Ÿ˜Ž
Focusing
  • Kathmandu
View GitHub Profile
-module(assignment3).
-export([fib/1, pieces/1]).
fib(0) ->
0;
fib(1) ->
1;
fib(N) when N > 1 ->
-module(assignment2).
-export([maxThree/3, howManyEqual/3]).
maxThree(X,Y,Z) ->
case lists:sort([X,Y,Z]) of
[_,_,M] -> M;
_ -> 0
end.
-module(first).
-export([double/1,mult/2,area/3,square/1,trebel/1]).
mult(X,Y) ->
X*Y.
double(X) ->
mult(2,X).
area(A,B,C) ->
@sushant12
sushant12 / first.erl
Last active May 4, 2020 07:15
implemented function to square and trebel a value
-module(first).
-export([double/1,mult/2,area/3,square/1,trebel/1]).
mult(X,Y) ->
X*Y.
double(X) ->
mult(2,X).
area(A,B,C) ->
@sushant12
sushant12 / curious_number.rb
Last active November 5, 2019 16:33
find curious numbers by string manipulation
class CuriousNumbers
attr_reader :digit, :largest_num
BASE_CURIOUS_NUMS = [0, 1, 5, 6].freeze
def initialize(digit)
@digit = digit.abs
@largest_num = ('9'*@digit).to_i
end
@sushant12
sushant12 / happy_number.rb
Created October 26, 2019 02:34
check for positive happy number in ruby
# a tail call optimized ruby script to find happy number
def happy_number?(num, seen_number = {})
# store num in hash for quick lookup
seen_number[num] = num
total = num
.to_s
.chars
.reduce(0) { |acc, digit| acc + digit.to_i ** 2 }
@sushant12
sushant12 / s3 cors
Created July 1, 2019 02:39
S3 cors enable
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
@sushant12
sushant12 / jira.js
Created May 24, 2019 11:46
jquery code to add scrollbar in the jira list
$.each($('.ghx-wrap-issue'), function(index, element) {
element.style.overflow = "auto"
element.style.height = "calc(100vh - 186px)"
})
@sushant12
sushant12 / nginx.conf
Created February 28, 2019 09:33
Nginx setup for hosting static sites
upstream puma {
server unix://home/deploy/apps/pte_backend/shared/tmp/sockets/pte_backend-puma.sock fail_timeout=0;
}
server {
server_name api.houseofenglish.online;
root /home/deploy/apps/pte_backend/current/public;
try_files $uri/index.html $uri @puma;
require 'resque/tasks'
require 'resque/scheduler/tasks'
task "resque:setup" => :environment do
Resque.before_fork = Proc.new do |job|
ActiveRecord::Base.connection.disconnect!
end
Resque.after_fork = Proc.new do |job|
ActiveRecord::Base.establish_connection
end