Skip to content

Instantly share code, notes, and snippets.

View vishnuroshan's full-sized avatar
🗺️
trying to make each day an adventure

Vishnu Roshan vishnuroshan

🗺️
trying to make each day an adventure
View GitHub Profile
@vishnuroshan
vishnuroshan / cycle.js
Last active March 20, 2024 14:33
Find number of rotations needed for the strings to match
function cycle(a, b) {
if (a.length !== b.length) return 0;
const arr = a.split('');
const temp = [...arr]; // i am copying the array.
let count = 0;
for(let e of arr) {
count += 1;
console.log(temp.join(''));
const firstElement = temp.shift(); // this removes the 1st element of the array
temp.push(firstElement);
@vishnuroshan
vishnuroshan / types.ts
Created August 11, 2023 10:40 — forked from ClickerMonkey/types.ts
Typescript Helper Types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// when T is a tuple, Y is returned, otherwise N
// valid tuples = [string], [string, boolean],
// invalid tuples = [], string[], (string | number)[]
const sum = (a) => (b) => b === undefined ? a : sum(a+b);
const arr = []
arr[0] = sum(1)(2)(3)(); // output: 6
arr[1] = sum(1)(2)(3)(1)(1)(2)(2)(10)(); // output: 22
console.log(arr);
@vishnuroshan
vishnuroshan / useState.js
Created June 9, 2023 12:50
A very crude imagination of how useState works internally in react (definitely wrong)
function useState(initVal) {
let _val = initVal;
let state = () => _val;
const setState = (newVal) => _val = newVal;
return [state, setState]
}
const [c, setC] = useState(1);
console.log(c());
setC(2);
@vishnuroshan
vishnuroshan / TS-generics-custom-array-every-method.ts
Last active July 5, 2023 12:11
Typescript custom array methods with generics. this is a exercise to understand how generics work and where to use them in real life
interface Array<T> {
customEvery(callback: (each: T, index?: number, array?: Array<T>) => boolean): boolean;
}
Array.prototype.customEvery = function(callback) {
let res= []
for (let i = 0; i < this.length; i++) res.push(callback(this[i], i, this));
return res.includes(false) ? false : true
}
{
"basics": {
"name": "Rajalakshmi Venkatramani",
"label": "Senior Executive Human Resources",
"picture": "",
"email": "raji.sowmi17@gmail.com",
"phone": "957-808-0626",
"website": "",
"summary": "Experienced Human Resource skilled in Recruitment, Administration, Performance Management & Payroll.\nGoals: Want to work in an organization where I get opportunity to groom & nurture myself. I want to work in an organization by integrating my goals with the organizational goal by using win - win strategy\nSpecialties: Strong in communication, good in interpersonal relationship and overall knowledge in HR \n",
"location": {
@vishnuroshan
vishnuroshan / resume.json
Last active April 26, 2022 19:16
JSON Resume
{
"meta": {
"theme": "elegant"
},
"basics": {
"name": "Vishnu Roshan",
"label": "Software Engineer at Sedin Technologies | open source enthusiast",
"picture": "",
"email": "vishnuroshan4@gmail.com",
"phone": "+91 99520 29597",