Skip to content

Instantly share code, notes, and snippets.

View christopherfujino's full-sized avatar
💻
Maybe coding

Christopher Fujino christopherfujino

💻
Maybe coding
View GitHub Profile
@christopherfujino
christopherfujino / array-assoc.md
Last active August 17, 2017 15:34
How to use Ruby's array.assoc method.

array.assoc(obj) => array or nil

The assoc method for Ruby arrays takes a single argument and searches for the matching element that is an array whose first element matches the argument. It then returns either the matching sub-array or nil if none was found.

This is a fairly common task in situations where a hash is used to collect a set of data and the keys are used as unique identifiers. I chose this method because I am tired of writing some form of the same basic function in JavaScript:

let beardLengths = [
  {name: 'cory', length: 5},
  {name: 'justin', length: 4}
@christopherfujino
christopherfujino / slack-ruby-gem.md
Last active August 30, 2017 18:17
Slack-api Gem

The slack-api provides a Ruby wrapper around the slack bot API. It can be installed with gem install slack-api. It is then included in Ruby applications as simply require "slack".

In order to access a slack team, you must first create a bot for your team through the Slack web app, and obtain a unique token associated with the team.

Here is sample code for a basic bot that logs each message that it receives to the terminal:

require "slack"

Jekyll: Static-Site Generator

With Jekyll, you can create a blog (or other site) out of static pages. What that means is that it doesn't have a database. Usually with a blog, you would store all of your posts in a database, and when a user goes to view the blog, the server would read the posts from the database and serve them to the user. With Jekyll, each time you write a new post, the entire website is re-built as static web pages, so that all the server has to do is serve the pre-built pages.

The advantage of building a static website is that there is less load on the server--all it has to do is give users the completed page they requested. These pages load lightning-fast, and they can be served to many users simultaneously. In addition, they can be hosted for free on platforms like Github Pages and Netlify.

With Jekyll, posts are written in markdown and compiled to HTML, making writing posts simple and the

@christopherfujino
christopherfujino / drive_test_stacktrace
Created April 11, 2019 21:46
drive test stacktrace
~/git/flutter/packages/flutter_tools$ pub run test test/commands/drive_test.dart
00:05 +14: drive restore AppStarter --no-build
about to fail...
DriveCommand
Failed assertion: boolean expression must not be null
#0 _startApp (package:flutter_tools/src/commands/drive.dart)
<asynchronous suspension>
#1 DriveCommand.runCommand (package:flutter_tools/src/commands/drive.dart:133:51)
<asynchronous suspension>
#2 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:559:18)

Flutter Attach

Overview

A Flutter-command that attaches to applications that have been launched without flutter run.

With an application already running, a HotRunner can be attached to it with:

#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: flutter-brew-linker.sh COMMAND"
echo "where COMMAND is either \"unlink\" or \"link\"."
exit 99
fi
COMMAND="$1"
@christopherfujino
christopherfujino / ios13-syslog
Created September 12, 2019 21:38
iphone Xr ios 13 sys log when plugging in device to mac host
default 14:35:12.310579 -0700 lockdownd spawn_xpc_service_block_invoke: <private>
default 14:35:12.310774 -0700 lockdownd spawn_xpc_service_block_invoke: <private>
default 14:35:12.312592 -0700 symptomsd L2 Metrics on en0: rssi: -69 [-68,-67] -> -69, snr: 32 (cca [wake/total] self/other/intf): [-1,-1]/[-1,-1]/[-1,-1]/14 (txFrames/txReTx/txFail): 10/0/0 -> (was/is) 0/0
default 14:35:12.312866 -0700 symptomsd Received Wi-Fi Assist Override along with LQM info: 0
default 14:35:12.314321 -0700 springboardservicesrelay Initializing connection
default 14:35:12.315842 -0700 springboardservicesrelay Removing all cached process handles
default 14:35:12.316265 -0700 springboardservicesrelay Sending handshake request attempt #1 to server
default 14:35:12.316555 -0700 springboardservicesrelay Creating connection to com.apple.runningboard
default 14:35:12.317222 -0700 runningboardd Incoming connection from 343, user 501
default 14:35:12.317553 -0700 runningboardd _resolveProcessWithIdentifier sysctl pid 343 is euid 501
@christopherfujino
christopherfujino / curl-devicelab-log.md
Created October 18, 2019 21:47
curl Flutter devicelab logs to a file
  1. Open Chrome dev tools on the build dashboard -> Application -> Cookies -> "X-Flutter-IdToken" copy and paste the value into your terminal as export FLUTTER_DASHBOARD_COOKIE=''
  2. Copy and paste the URL of the specific task logs to your terminal as export LOGS_URL='https://logs.url/'
  3. Then curl the logs to a local file: curl "$LOGS_URL" -b "X-Flutter-IdToken=${FLUTTER_DASHBOARD_COOKIE}" | tee dashboard-logs.txt
@christopherfujino
christopherfujino / patch.diff
Created May 12, 2020 22:45
pin customer_testing for stable hotfix
From bad9a44031fc9b1721d6ab1fc746d21d2fa76def Mon Sep 17 00:00:00 2001
From: Christopher Fujino <christopherfujino@gmail.com>
Date: Tue, 12 May 2020 15:42:28 -0700
Subject: pin customer_testing
---
.cirrus.yml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/.cirrus.yml b/.cirrus.yml
@christopherfujino
christopherfujino / refactor.diff
Created May 15, 2020 18:44
bin/flutter -> bin/shared.sh diff
diff --git a/bin/flutter b/bin/shared.sh
index 87bd59711..a9de7f131 100755
--- a/bin/flutter
+++ b/bin/shared.sh
@@ -16,25 +16,6 @@ set -e
unset CDPATH
-function follow_links() {
- cd -P "${1%/*}"