Skip to content

Instantly share code, notes, and snippets.

Adaptive Widgets for Flutter

Built-in adaptive widgets

Flutter has several widgets that have built-in adaptive features showing a styled widget that adapts to the currently platform (Cupertino or Material).

Icon(
@patrickward
patrickward / expo-typescript-eslint-prettier.md
Created October 20, 2021 14:42 — forked from yovany-lg/expo-typescript-eslint-prettier.md
Setting up React Navite: Expo + Typescript + Eslint (Airbnb) + Prettier

Steps to get started with Expo, Typescript, ESLint and Prettier

The first step is to use the Expo CLI to initialize the project. If you don't have the latest version of the Expo CLI tool, (or you don't have it installed) run npm install -g expo-cli.

Now run the following commands in the same order:

  • expo init my-app -t expo-template-blank-typescript
  • npx install-peerdeps --dev eslint-config-airbnb
  • npm i --save-dev @typescript-eslint/parser @typescript-eslint/eslint-plugin
  • npm i --save-dev prettier eslint-config-prettier eslint-plugin-prettier

Create or edit the file .eslintrc.json with the following content:

@patrickward
patrickward / user-story-example
Last active September 22, 2022 13:43
User Story Example
Sourced from: https://medium.com/swlh/user-story-template-with-examples-244528bf9e7
Title: Returns and exchanges go to inventory.
Story
-----
As a store owner,
I want to add items back to inventory when they are returned or exchanged,
so that I can track inventory.
@patrickward
patrickward / latency.txt
Created May 16, 2018 18:56 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@patrickward
patrickward / pedantically_commented_playbook.yml
Last active August 30, 2015 18:51 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@patrickward
patrickward / batch-selective-blur
Last active April 15, 2022 12:47
Batching the selective blur filter in Gimp
;; Batch processes all files within the current directory
;; by running a selective blur on each image and then saving them
;; WARNING: edits the original file. Run this on copies of the original images.
;;
;; Save the script below in the local gimp scripts directory
;; (e.g. ~/.gimp-2.8/scripts/batch-selective-blur.scm)
;;
;; Example execution:
;; gimp -i -b '(batch-selective-blur "*.jpg" 6.0 31)' -b '(gimp-quit 0)'
;;
@patrickward
patrickward / avconv-mp4-to-jpg
Created December 5, 2013 03:39
Convert mp4 to jpg with avconv/ffmpeg
avconv -i inbound.mp4 -vsync 1 -r 0.1 -an -y 'outbound-folder/video-clip-%4d.jpg'
@patrickward
patrickward / minitest_spec_expectations.md
Created March 26, 2012 09:48 — forked from ordinaryzelig/minitest_spec_expectations.md
How to write MiniTest::Spec expectations

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations
@patrickward
patrickward / gist:1615980
Created January 15, 2012 14:17
Using Guard programmatically
require 'guard/willow'
config = @global_config
options = Willow.configure(config)
paths = options[:paths]
source = File.expand_path(options[:source])
guardfile = <<-EOS
guard 'willow', :source => '#{source}' do
watch(%r{^#{paths[:assets]}/.*})