Skip to content

Instantly share code, notes, and snippets.

View nkgokul's full-sized avatar

Gokul N K nkgokul

View GitHub Profile
@nkgokul
nkgokul / logo-commands
Created December 17, 2021 14:47
Logo Commands
clearscreen repeat 360 [fd repcount rt repcount]
@nkgokul
nkgokul / persistence.js
Last active August 24, 2021 02:00
Persistence of a number
function digit_product(number) {
let digit_product = 1;
while (number) {
digit_product *= number % 10;
number = Math.floor(number / 10);
}
return digit_product;
}
function persistence(number) {
@nkgokul
nkgokul / LICENSE
Last active June 12, 2021 11:17 — forked from yanofsky/LICENSE
A script to download all of a user's tweets into a csv
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@nkgokul
nkgokul / api.xony.io-twitter-naval-medium.js
Created December 10, 2020 11:36
api.xony.io/twitter/naval/medium
[
{
"medium": "https://medium.com/@naval"
}
]
@nkgokul
nkgokul / api.xony.io-twitter-naval.js
Created December 10, 2020 11:33
api.xony.io/twitter/naval
[
{
"medium": "https://medium.com/@naval"
},
{
"twitter":"https://twitter.com/gokulnk"
}
]
@nkgokul
nkgokul / sentry_fractional_logging.js
Created December 24, 2019 20:01
Sentry Fractional Logging
const percentateOfErrorsToLog = 30;
const percentateOfErrorsToLogFraction = percentateOfErrorsToLog/100;
const threshold = 1 - percentateOfErrorsToLogFraction;
try {
someErrorCasuingFunction();
}
catch(error) {
if(Math.random() >= threshold) {
Sentry.captureException(error);
}
@nkgokul
nkgokul / check_rand_function_distribution.js
Created December 24, 2019 19:46
Check rnadom function distribution
function checkUniformDistributionOfRandom(percentateOfErrorsToLog = 10) {
const percentateOfErrorsToLogFraction = percentateOfErrorsToLog/100;
const threshold = 1 - percentateOfErrorsToLogFraction;
const numberOfLoops = 1000;
for (let i=1; i<numberOfLoops; i++){
if (Math.random() >= threshold) console.log("This should be printed " + percentateOfErrorsToLogFraction * numberOfLoops + " times");
}
}
[10, 20, 30, 40, 50, 60, 70, 80, 90].map(checkUniformDistributionOfRandom);
@nkgokul
nkgokul / recursive_digit_sum
Last active September 14, 2019 09:37
Recursive Digit Sum
{
function recuresiveDigitSumMaths(number) {
finalRecuresiveDigitSum = 0;
while (number) {
digit = number % 10;
finalRecuresiveDigitSum += digit;
if (finalRecuresiveDigitSum > 9) finalRecuresiveDigitSum -= 9;
number = (number - digit) / 10
}
@nkgokul
nkgokul / recursive_digit_sum
Created September 14, 2019 08:46
Recursive Digit Sum
{
function recuresiveSum(number){
finalRecursiveSum = 0;
while(number){
digit = number % 10;
finalRecursiveSum += digit;
if (finalRecursiveSum>9) finalRecursiveSum -=9;
number = (number-digit)/10
}
return (finalRecursiveSum);