Skip to content

Instantly share code, notes, and snippets.

Junji Zhi junjizhi

Block or report user

Report or block junjizhi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
junjizhi / download_kernel_if_not_exist.makefile
Created Dec 12, 2013
Makefile: how to write conditional in the target implementation script
View download_kernel_if_not_exist.makefile
if [ ! -e $(LINUX_TAR_NAME) ] ; \
then \
wget $(LINUX_TAR_SITE) ; \
tar -xf $(LINUX_TAR_NAME) && \
junjizhi /
Created Dec 15, 2013
delete file not ending with a certain format
#delete files or dirs whose name does not end with '.sh' in the current path
ls | grep -v '\.sh$' | xargs rm -r
#However, this way does not solve the problem that the path names that have spaces, for example, "cmp\ output"
#more robust version
find . -maxdepth 1 -type f ! -iname '*.pdf' -delete
#if we need to delete the directories, too, then remove '-type f'
junjizhi /
Created Dec 15, 2013
Multiple conditions in the shell. if condition
if [ -e $DIR1 ] && [ -e $DIR2 ] || [ -e $DIR3 ]
echo "do sth"
junjizhi /
Created Dec 20, 2013
For loop in shell
#equel to for (int i=1; i<num; i++) in c/c++, java
for i in $(seq 1 $NUM);
echo $i
View ethergist
junjizhi / copy-word.el
Created Feb 1, 2019
Emacs: copy word without selection
View copy-word.el
(defun jz/copy-word
"Copy words at point into kill-ring.
Adapted from
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.
junjizhi / Insert-Date.workflow
Created Apr 8, 2019
Applescript: Insert Date and A Horizontal Divider Line
View Insert-Date.workflow
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
junjizhi / cupertino-clickable-card.dart
Created Jun 16, 2019
iOS style clickable card demo
View cupertino-clickable-card.dart
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Clickable Card',
junjizhi / main_page.dart
Last active Jul 13, 2019
Flutter BLoC and Provider: A Shopping Cart Example
View main_page.dart
// 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
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);
junjizhi / cart_page.dart
Last active Jul 13, 2019
Flutter BLoC and Provider: A Shopping Cart Example - Shopping Cart Page
View cart_page.dart
class CartPage extends StatelessWidget {
CartPage({Key key}) : super(key: key);
Widget build(BuildContext context) {
var bloc = Provider.of<CartBloc>(context);
var cart = bloc.cart;
return Scaffold(
You can’t perform that action at this time.