View resize.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euxo pipefail | |
# Usage: | |
# cd /path/to/images/directory | |
# bash resize.bash | |
shopt -s extglob | |
for filename in [^resize]*.?(jpg|jpeg|png); do | |
newFile="resized-$filename" |
View find-sqlite-db-ios-simulator.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns all db files sorted by modified time. Usually the last one is your sqlite db file. | |
gfind /Users/<username>/Library/Developer/CoreSimulator/Devices/ -name "*.db" -printf "%T+\t%p\n" | sort |
View main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/junjizhi/flutter-shopping-cart | |
import 'cart_bloc.dart'; | |
import 'package:provider/provider.dart'; | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return ChangeNotifierProvider<CartBloc>( | |
builder: (context) => CartBloc(), | |
child: MaterialApp( |
View cart_bloc.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class CartBloc with ChangeNotifier { | |
Map<int, int> _cart = {}; | |
Map<int, int> get cart => _cart; | |
void addToCart(index) { | |
if (_cart.containsKey(index)) { | |
_cart[index] += 1; |
View cart_page.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/junjizhi/flutter-shopping-cart | |
class CartPage extends StatelessWidget { | |
CartPage({Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
var bloc = Provider.of<CartBloc>(context); | |
var cart = bloc.cart; | |
return Scaffold( |
View main_page.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a pseudo code to show the overall structure | |
// of a main page of a shopping cart app built with Flutter. | |
// For the complete app, please see https://github.com/junjizhi/flutter-shopping-cart | |
Widget build(BuildContext context) { | |
var bloc = Provider.of<CartBloc>(context); | |
int totalCount = 0; | |
if (bloc.cart.length > 0) { | |
totalCount = bloc.cart.values.reduce((a, b) => a + b); | |
} |
View cupertino-clickable-card.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter/cupertino.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Clickable Card', |
View Insert-Date.workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run {input, parameters} | |
set _Date to short date string of (current date) | |
set _DividerLine to "-----------------------------------------------------------------------------------------------" | |
set clipboard_contents to (the clipboard) | |
set the clipboard to _Date & return & _DividerLine & return | |
tell application "System Events" to keystroke "v" using command down | |
delay 0.2 -- needed because otherwise the next command can run before the paste occurs | |
set the clipboard to clipboard_contents | |
end run |
View copy-word.el
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun jz/copy-word | |
(&optional | |
arg | |
) | |
"Copy words at point into kill-ring. | |
Adapted from https://www.emacswiki.org/emacs/CopyWithoutSelection#toc4 | |
The original implementation doesn't work if the cursor is at the beginning of current word. It copies one word back instead. | |
With this tweak, this function works in that case, but won't work if the current cursor is at the end of current word. |
View ethergist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0xFe1Bab4f773e3159721d1bFce550cf1217a22e2E |
NewerOlder