Skip to content

Instantly share code, notes, and snippets.

View kharioki's full-sized avatar
🤘
I'm burdened with glorious purpose

Tony Kharioki kharioki

🤘
I'm burdened with glorious purpose
View GitHub Profile
'use strict';
const fs = require('fs');
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
@kharioki
kharioki / mario.c
Created January 10, 2019 11:47
mario staircase c
#include <cs50.h>
#include <stdio.h>
int get_positive_int(string prompt);
int main(void)
{
int h = get_positive_int("Height: ");
for (int i = 0; i < h; i++) {
for ( int j = h - i; j > 1; j--) {
printf(" ");
@kharioki
kharioki / main.dart
Created April 20, 2020 22:13
Flutter Lists
import 'dart:math';
void main() {
List<String> myList = [
'Angela',
'Tony',
'June',
'Tessie'
];
@kharioki
kharioki / main.dart
Last active April 20, 2020 22:37
Inheritance of Action
// Inheritance of Actions
void main() {
// Car myNormalCar = Car();
// myNormalCar.drive();
// print(myNormalCar.numberOfSeats);
@kharioki
kharioki / main.dart
Created April 20, 2020 23:56
class constructors in dart
// Class constructors
void main() {
Human june = Human(165, 120);
print(june.height);
print(june.weight);
Human tony = Human(170, 140);
print(tony.height);
@kharioki
kharioki / docker-help.md
Created May 17, 2020 10:01 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@kharioki
kharioki / useLocalStorage.js
Created February 21, 2021 16:56
A useLocalStorage react hook
// Hook
export default function useLocalStorage(key, initialValue) {
// State to store our value
// Pass initial state function to useState so logic is only executed once
const [storedValue, setStoredValue] = useState(() => {
try {
// Get from local storage by key
const item = window.localStorage.getItem(key);
// Parse stored json or if none return initialValue
return item ? JSON.parse(item) : initialValue;
@kharioki
kharioki / maxSubArray.js
Created May 24, 2021 15:08
Finding the maximum subarray.
let arr1 = [13, -3, -25, 20, -3, -16, -23, 18, 20, -7, 12, -5, -22, 15, -4, 7];
function maxSubArray (nums) {
let maxC = nums[0];
let maxG = nums[0];
for (let i = 1; i < nums.length; i++) {
maxC = Math.max(nums[i], maxC + nums[i]);
maxG = maxC > maxG ? maxC : maxG;
}
@kharioki
kharioki / dropdown.js
Created June 30, 2021 03:16
A basic dropdown component implemented with react
/*
Prompt:
We have defined a basic dropdown via the Dropdown and DropdownItem components below, with example usage
in the ExampleNav component. The Dropdown and DropdownItem components have some problems, and also
have room for improvements (doesn't everything?) A couple items TODO here (make sure to explain with comments!)
0. How are you today? 😊
I am great. This is an interesting exercise
1. Please fix any obvious issues and make you see with the dropdown.
@kharioki
kharioki / countBits.js
Last active July 4, 2021 10:52
countBits
const countBits = n => n.toString(2).split('0').join('').length
countBits(1234);