Skip to content

Instantly share code, notes, and snippets.

View htchaan's full-sized avatar

htc htchaan

  • Hong Kong
View GitHub Profile
extension View {
func flexible(width: Bool, height: Bool) -> some View {
self.modifier(MatchingParentModifier(width: width, height: height))
}
}
struct MatchingParentModifier: ViewModifier {
@State private var intrinsicSize: CGSize = UIScreen.main.bounds.size
private let intrinsicWidth: Bool
private let intrinsicHeight: Bool
@joshtynjala
joshtynjala / profiles.json
Created August 8, 2019 15:46
Ayu color schemes for Windows Terminal
{
"schemes" :
[
{
"background" : "#fafafa",
"black" : "#000000",
"blue" : "#3199e1",
"brightBlack" : "#686868",
"brightBlue" : "#399ee6",
"brightCyan" : "#4cbf99",
@vraravam
vraravam / osx-defaults.sh
Last active March 17, 2024 01:21
OSX Defaults to setup a brand new machine
#!/usr/bin/env bash
# TODO: Need to figure out the settings for the following:
# 1) Dock: Items with order (not capturing binary data - since that is dependent on installed apps)
# 2) Security & Privacy Preferences: Full Disk Access, Camera, Microphone
# 3) Login items for my user (i.e. apps started when I login)
# 4) Retina displays scaling
# 5) Finder sidebar with order
##
@johnxx
johnxx / cssgrep.sh
Created August 24, 2018 21:01
Use html-xml-utils like grep with CSS selectors
#!/bin/bash
if ! which hxselect > /dev/null; then
echo You need hxselect and hxnormalize
echo Run this: sudo apt-get install html-xml-utils
exit 1
fi
hxselect="hxselect -s \n -i"
hxnormalize="hxnormalize -l 10000000 -x "
@jaytaylor
jaytaylor / gitmodules-sorter.md
Created May 4, 2017 17:41
Sort .gitmodules, also easily adaptable to sort files in blocks (e.g. 4 lines at a time, or arbitrary region at a time).
@HyperBrain
HyperBrain / package-plugin-lifecycle.md
Last active November 24, 2023 04:56
Serverless - Package/Deploy plugin lifecycle changes

Overview

Currently the Serverless framework only offers lifecycle events that are bound to commands and also are very coarse. Each core plugin only exposes the events that are defined by the framework. This is suboptimal for plugin authors as they want to hook special events within the deployment process.

The PR adds fine grained lifecycles to the AWS deployment process (see below for the current implementation process) and makes the package/deploy plugin implementation non-breaking.

@amake
amake / android-7-localization.org
Last active July 25, 2023 22:34
Correct localization on Android 7

Correct localization on Android 7

Prior to Android 7, the system had a single preferred locale, and fallback behavior was quite rudimentary. Starting with Android 7, the user can now specify a priority list of locales, and fallback behavior is improved.

However, in many cases it is still surprisingly difficult to make full use of locale fallback, and there are some hidden gotchas when trying to fully support both Android 7 and earlier versions.

@sc0rch
sc0rch / MainActivity.java
Created July 9, 2016 01:45
Clear focus on touch outside for all EditText inputs.
public class MainActivity extends Activity
// ... any code
/**
* Clear focus on touch outside for all EditText inputs.
*/
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
View v = getCurrentFocus();
@ckressibucher
ckressibucher / cliserver.php
Last active November 10, 2023 17:58
Router script for PHP built in server
<?php
// public/cliserver.php (router script)
if (php_sapi_name() !== 'cli-server') {
die('this is only for the php development server');
}
if (is_file($_SERVER['DOCUMENT_ROOT'].'/'.$_SERVER['SCRIPT_NAME'])) {
// probably a static file...
return false;
# script insstalls qemu and vagrant, then uses vagrant to build a qemu-
# supported rpi kernel for dev.
# - tested with 2015-02-16-raspbian-wheezy.zip on OSX El Capitan
# Variables
IMAGE=http://downloads.raspberrypi.org/raspbian_latest
IMG_PATH="/vagrant/raspbian_latest.img"
PI_LINUX=https://github.com/raspberrypi/linux
PI_LINUX_BRANCH="rpi-4.2.y"
PI_TOOLS=https://github.com/raspberrypi/tools