#Recursive version which we will write mostly!
def fibonacciVal(n)
if n == 0
return 0
elsif n == 1
return 1
else
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
class Client: | |
def coin_list(self): | |
return False | |
def coin_snapshot_full_by_id(self, coin_id): | |
return False | |
def coin_snapshot(self, fsym, tsym): | |
return False |
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
# | |
# Old code, which has a loop and sends API call for each video ID | |
# | |
video_ids.map do |video_id| | |
Yt::Video.new(id: video_id).select(:snippet, :content_details, :statistics, :status) | |
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
~$ node | |
> var calculatedChecksum = 1513135 | |
// Anding an integer with 0xFF leaves only the least significant byte. | |
// For example, to get the first byte, we can write "<int value> & 0xFF" | |
// This is typically referred to as "masking" | |
> var firstByte = calculatedChecksum & 0XFF | |
// 0XFF00 is hexadecimal, We are masking out the lower byte of your number, | |
// then bit-shifting all of the bits to the right by 8. |
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
// Final code | |
var MayApp = {}; | |
MyApp.Base = { | |
data: { | |
rules: { | |
FirstSet:{ | |
"0-12": { | |
"0-12000":{ | |
"0-90" :{ | |
fixedVal: 0.4 |
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
// intermediate code | |
var MyApp = {}; | |
MyApp.Base = { | |
data: { | |
rules: { | |
FirstSet:{ | |
"0-12": { | |
"0-12000":{ | |
"0-90" :{ |
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
DEFINE amount, fixedVal, myDataVal | |
IF RANGE(0 - 12) INCLUDES myDataVal | |
IF RANGE(0,12000) INCLUDES amount | |
IF RANGE(0,95) INCLUDES calculatedVal | |
RETURN 0.8 | |
ELSEIF RANGE(95,*) INCLUDES calculatedVal | |
RETURN 0.7 |
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 MyApp = {}; | |
MyApp.Base = { | |
getFixedVal: function(){ | |
//Javascript code before refactoring | |
var myDataVal = someCalculationHere(); | |
var amount = someInputFieldValue; | |
var fixedVal = 0; | |
if(myDataVal > 12){ | |
if(0 < amount && amount <= 12000){ |
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
// Final code | |
var MayApp = {}; | |
MyApp.Base = { | |
data: { | |
rules: { | |
FirstSet:{ | |
"0-12": { | |
"0-12000":{ | |
"0-90" :{ | |
fixedVal: 0.4 |
NewerOlder