Skip to content

Instantly share code, notes, and snippets.

View YBCS's full-sized avatar
💭

Y. Budhachandra YBCS

💭
View GitHub Profile
@YBCS
YBCS / day1.py
Created December 1, 2023 07:11
aoc day 1
data = open('input.txt', 'r').read().split('\n')
def part1(data):
nums = "123456789"
ans = 0
for word in data:
l = 0
r = len(word)-1
print('cur word ', word)
while word[l] not in nums:
@YBCS
YBCS / App.js
Created August 16, 2020 20:52
fullstack part 7 ex 7.7
// Ex 7.7
const useCountry = (name) => {
const [country, setCountry] = useState(null)
useEffect(() => {
if (name !== '') {
axios.get(`https://restcountries.eu/rest/v2/name/${name}?fullText=true`)
.then((response) => {
setCountry({...response, found: true})
@YBCS
YBCS / App.js
Created July 20, 2020 14:49
part5 ex8 weird like update
//src/App.js
const newLike = async (blogObject) => {
// here
try {
const returnedBlog = await blogService.update(
blogObject.id,
blogObject.body
)
setBlogs(
@YBCS
YBCS / basic.dart
Created November 24, 2019 09:12
some basic stuff on dart
// This is the basics
void main() => runApp(MaterialApp(
// home: Text('hey ninjas!'),
// notice : the widgets starts with upper case
// coma follows every property / widgets
home: Scaffold(
appBar: AppBar(
title: Text('my first app'),
centerTitle: true,
@YBCS
YBCS / bicycle.dart
Created October 31, 2019 16:14
#1 codelabs --> Intro to Dart for Java devs!
class Bicycle {
int cadence;
int _speed = 0; // makes it private
// private so explicit -- getter
int get speed => _speed;
// implicit getters and setters for all public instance variables
int gear;
Bicycle(this.cadence, this.gear);
@YBCS
YBCS / scream.dart
Created October 31, 2019 16:12
#6 codelabs --> Intro to Dart for Java devs!
// Impreratice code (not functional-style)
// String scream(int length) => "A${'a' * length}h!";
// main() {
// final values = [1, 2, 3, 5, 10, 50];
// for (var length in values) {
// print(scream(length));
// }
// }
@YBCS
YBCS / shape.dart
Created October 31, 2019 16:08
#4 create a factory of codelabs --> Intro to Dart for Java devs!
import 'dart:math';
// 2 Create a factory constructor
abstract class Shape {
factory Shape(String type) {
if (type == 'circle') return Circle(2);
if (type == 'square') return Square(2);
throw 'Can\'t create $type.';
}
num get area;