Skip to content

Instantly share code, notes, and snippets.

View hongsw's full-sized avatar
๐Ÿ•น๏ธ
Focusing

Seungwoo hong hongsw

๐Ÿ•น๏ธ
Focusing
View GitHub Profile
@hongsw
hongsw / main.dart
Created September 12, 2023 16:16
FizzBuzz in Dart without IF
void main() {
for (int i = 1; i <= 100; i++) {
String output = "";
var fizz = ["", "Fizz"];
var buzz = ["", "Buzz"];
output += fizz[i % 3 == 0 ? 1 : 0];
output += buzz[i % 5 == 0 ? 1 : 0];
@hongsw
hongsw / main.dart
Last active September 12, 2023 15:57
Dart 'PPAP' Songย 
void main() {
// ๋‹จ๊ณ„ 1: ๐ŸŽ + ๐Ÿ–Š = ๐ŸŽ๐Ÿ–Š
String pen = '๐Ÿ–Š';
print('Pen: $pen'); // ๐Ÿ–Š
String apple = '๐ŸŽ';
print('Apple: $apple'); // ๐ŸŽ
String ap = apple + pen;
print('AP: $ap'); // ๐ŸŽ๐Ÿ–Š
// ๋‹จ๊ณ„ 2: ๐Ÿ + ๐Ÿ–Š = ๐Ÿ๐Ÿ–Š
@hongsw
hongsw / main.dart
Last active September 12, 2023 15:54
dart string functions
void main() {
var hello = 'Hello, ๐ŸŒ!';
print(hello.toUpperCase()); // Output: "HELLO, ๐ŸŒ!"
hello = 'Hello, ๐ŸŒ!';
print(hello.toLowerCase()); // Output: "hello, ๐ŸŒ!"
hello = ' Hello, ๐ŸŒ! ';
print(hello.trim()); // Output: "Hello, ๐ŸŒ!"
@hongsw
hongsw / get_flutter_sample_game_template.sh
Created September 4, 2023 21:24
to get game_template only in sample repo, https://flutter.dev/games
git clone --filter=blob:none --no-checkout --depth 1 --sparse https://github.com/flutter/samples.git
cd samples
ls
git sparse-checkout add game_template
git checkout
ls
@hongsw
hongsw / main.dart
Last active May 24, 2023 04:34
guardianapis ์ด์šฉ ์˜ˆ์‹œย 
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> fetchPosts() async {
final response =
await http.get(Uri.parse('https://content.guardianapis.com/search?show-fields=thumbnail&q=food%20korean&api-key=test'));
if (response.statusCode == 200) {
// API ์„œ๋ฒ„์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ •์ƒ์ ์œผ๋กœ ๊ฐ€์ ธ์™”์„ ๋•Œ
@hongsw
hongsw / main.dart
Created May 23, 2023 22:10
crimson-patter-5991
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> fetchPosts() async {
final response =
await http.get(Uri.parse('https://jsonplaceholder.typicode.com/posts'));
if (response.statusCode == 200) {
// API ์„œ๋ฒ„์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ •์ƒ์ ์œผ๋กœ ๊ฐ€์ ธ์™”์„ ๋•Œ
@hongsw
hongsw / main.dart
Created May 23, 2023 15:53
fascinating-kingdom-4671
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class CounterModel extends ChangeNotifier {
int _count = 0;
int get count => _count;
void increment() {
_count++;
notifyListeners();
@hongsw
hongsw / main.dart
Created May 17, 2023 03:05
bold-performance-3806
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@hongsw
hongsw / main.dart
Created May 17, 2023 03:05
cylindrical-dart-2948
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(