Skip to content

Instantly share code, notes, and snippets.

View popeyelau's full-sized avatar
:octocat:
To the stars!

Popeye Lau popeyelau

:octocat:
To the stars!
View GitHub Profile
@seblegall
seblegall / reverseproxy.go
Last active October 16, 2025 06:16
A reverse proxy in Golang using Gin
package main
import (
"fmt"
"net/http"
"net/http/httputil"
"net/url"
"github.com/gin-gonic/gin"
)
@vital-edu
vital-edu / main.dart
Last active September 25, 2024 06:13
How to overlap SliverList on a SliverAppBar
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'How to overlap SliverList on a SliverAppBar',
debugShowCheckedModeBanner: false,
@tomalabaster
tomalabaster / init_in_main.dart
Created March 1, 2020 01:06
GOOD: Async init done in main method
void main() async {
WidgetsFlutterBinding.ensureInitialized();
var databasesPath = await getDatabasesPath();
var path = join(databasesPath, 'example.db');
var database = await openDatabase(path, version: 1, onCreate: (db, version) async {
await db.execute('''CREATE TABLE MyTable (
id INTEGER PRIMARY KEY,
name TEXT)''');
@ggichure
ggichure / main.dart
Created October 17, 2019 18:54
flutter theme changer and persist with shared prefrences
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
//https://stackoverflow.com/a/53107519/10409567
void main() async {
// load the shared preferences from disk before the app is started
WidgetsFlutterBinding.ensureInitialized();
final prefs = await SharedPreferences.getInstance();
// create new theme controller, which will get the currently selected from shared preferences
@nekonynn
nekonynn / database_helper.dart
Last active September 15, 2020 11:53
SQFlite Implementation
import 'package:food_cookbook/repo/food_repo_contract.dart';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
class DatabaseHelper {
static final DatabaseHelper _instance = DatabaseHelper.internal();
factory DatabaseHelper() => _instance;
static Database _db;
# Luke's config for the Zoomer Shell
# Enable colors and change prompt:
autoload -U colors && colors
PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
# History in cache directory:
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.cache/zsh/history
@codinghivedev
codinghivedev / get_file_name.dart
Last active July 16, 2020 02:17
To get file name in Flutter
import 'package:path/path.dart' as path;
class AppUtil{
static Future<String> getFileNameWithExtension(File file)async{
if(await file.exists()){
//To get file name without extension
//path.basenameWithoutExtension(file.path);
@denniske
denniske / custom-solution.dart
Last active May 30, 2021 09:48
Flutter Modal bottom sheet will not overlap keyboard (Fixed)
import 'package:flutter/material.dart';
class CustomPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(),
floatingActionButton: FloatingActionButton(
onPressed: () {
showModalBottomSheet(
@yrom
yrom / main.dart
Created August 1, 2019 11:37
calculate fps in flutter app
var orginalCallback;
void main() {
runApp(...);
orginalCallback = window.onReportTimings;
window.onReportTimings = onReportTimings;
}
const maxframes = 60;
final lastFrames = ListQueue<FrameTiming>(maxframes);
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active November 5, 2025 09:59
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized