Skip to content

Instantly share code, notes, and snippets.

View superhard's full-sized avatar
🎯
Focusing

Artem superhard

🎯
Focusing
View GitHub Profile
@groz
groz / sync-http.swift
Created February 15, 2018 22:29
Synchronous http request in Swift
import Foundation
func query(address: String) -> String {
let url = URL(string: address)
let semaphore = DispatchSemaphore(value: 0)
var result: String = ""
let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in
result = String(data: data!, encoding: String.Encoding.utf8)!
@slightfoot
slightfoot / main.dart
Last active November 27, 2023 14:06
Example of using PageStorage to store data during usage of a PageView.
import 'package:flutter/material.dart';
void main() => runApp(new MainWidget());
class MainWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
@putraxor
putraxor / rich_text_view.dart
Created April 25, 2018 05:59
Flutter rich text view with clickable hyperlink
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart' as launcher;
///TODO: check performance impact bro !!!
class LinkTextSpan extends TextSpan {
LinkTextSpan({TextStyle style, String url, String text})
: super(
style: style,
@netsmertia
netsmertia / main.dart
Created May 4, 2018 13:53
flutter image drawing in canvas
import 'package:flutter/material.dart';
import 'dart:ui' as ui;
import 'package:flutter/services.dart' show rootBundle;
import 'dart:async';
import 'dart:typed_data';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@matteocrippa
matteocrippa / flutter.md
Last active April 20, 2025 03:41
Flutter Cheatsheet

Flutter

A quick cheatsheet of useful snippet for Flutter

Widget

A widget is the basic type of controller in Flutter Material. There are two type of basic Widget we can extend our classes: StatefulWidget or StatelessWidget.

Stateful

StatefulWidget are all the widget that interally have a dynamic value that can change during usage. It can receive an input value in the constructor or reference to functions. You need to create two classes like:

@Rich-Harris
Rich-Harris / what-is-svelte.md
Last active May 17, 2025 18:38
The truth about Svelte

I've been deceiving you all. I had you believe that Svelte was a UI framework — unlike React and Vue etc, because it shifts work out of the client and into the compiler, but a framework nonetheless.

But that's not exactly accurate. In my defense, I didn't realise it myself until very recently. But with Svelte 3 around the corner, it's time to come clean about what Svelte really is.

Svelte is a language.

Specifically, Svelte is an attempt to answer a question that many people have asked, and a few have answered: what would it look like if we had a language for describing reactive user interfaces?

A few projects that have answered this question:

enum AppDirectories: String {
case documents = "Documents"
case index = "Index"
case libary = "Library"
case temp = "Temp"
}
protocol AppDirectoryNames{
func documentsDirectoryURL() -> URL
func indexDirectoryURL() -> URL
import UIKit
protocol RouterProtocol: Presentable {
func present(_ module: Presentable?)
func present(_ module: Presentable?, animated: Bool)
func push(_ module: Presentable?)
func push(_ module: Presentable?, transition: UIViewControllerAnimatedTransitioning?)
func push(_ module: Presentable?, transition: UIViewControllerAnimatedTransitioning?, animated: Bool)
import UIKit
import Photos
import Contacts
import AVFoundation
enum Permission {
case cameraUsage
case contactUsage
case photoLibraryUsage
@SergLam
SergLam / AppTypeDefinitions.swift
Last active March 18, 2024 09:09
Photo selection service class for iOS
typealias Localizable = R.string.localizable
typealias TypeClosure<T> = (T) -> Void
typealias VoidClosure = () -> Void
typealias VoidResult = Swift.Result<Void, Error>
typealias VoidResultClosure = (Swift.Result<Void, Error>) -> Void
typealias ImagePickerConfiguration = (source: UIImagePickerController.SourceType,
isLimited: Bool,