Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
💯

Yusuke Konishi konifar

💭
💯
View GitHub Profile
@konifar
konifar / slack_invite_all.py
Created Aug 12, 2021
特定のSlackチャネルに全メンバーを一括招待するCode by Zapier
View slack_invite_all.py
import json
import urllib.request
import urllib.parse
import urllib.error
API_BASE_URL = 'https://slack.com/api'
ALL_MEMBER_CHANNEL_ID = 'xxxxxxxx' # #generalなど、全メンバーが入っている元となるチャネルのID
def load_channel_info(channel_id, token):
"""指定したチャネルの情報を取得する
@konifar
konifar / slack_public_channels_list.js
Created Dec 21, 2020
SlackのPublicチャネル一覧を書き出すGoogle Apps Script
View slack_public_channels_list.js
const slackApiUrl = 'https://slack.com/api';
const slackToken = 'xoxp-hogehoge';
function execute() {
// 現在日時を取得
const currentDate = new Date();
// チャネル一覧を取得
let url = slackApiUrl + '/conversations.list';
url += '?token=' + slackToken;
@konifar
konifar / what_today_is.js
Created Dec 12, 2020
今日は何の日かをSlack通知するGoogle App Script
View what_today_is.js
const webhookUrlForTest = 'https://hooks.slack.com/services/xxxxxxxx'
const webhookUrl = 'https://hooks.slack.com/services/xxxxxxxx'
function execute() {
// 今日の年月日を取得
const date = new Date();
const todayYear = date.getFullYear();
const todayMonth = date.getMonth() + 1;
const todayDay = date.getDate();
const dayOfWeek = ["日", "月", "火", "水", "木", "金", "土"][date.getDay()];
View skip_smart_lock.kt
fun skipSmartLock() {
val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
val noneButton = device.findObject(UiSelector().textMatches("(上記以外)|(NONE OF THE ABOVE)").className("android.widget.Button"))
if (noneButton.exists()) {
noneButton.click()
}
}
@konifar
konifar / auto_remove_unused_resources.sh
Last active May 15, 2018
auto_remove_unused_resources.sh
View auto_remove_unused_resources.sh
#!/bin/bash -xe
# Usage:
# ./auto_remove_unused_resources.sh {github token} master
readonly GITHUB_TOKEN=${1}
readonly BASE_BRANCH=${2}
readonly ROOT_DIR=$PWD
readonly SRC_DIR="app/src"
readonly COMPARE_BRANCH="remove_unused_resources"
@konifar
konifar / android_unused_resource_remover.py
Created Apr 20, 2018
android_unused_resource_remover.py
View android_unused_resource_remover.py
# -*- coding: utf-8 -*-
import commands
import glob
import os
import xml.etree.ElementTree as ElementTree
# http://stackoverflow.com/questions/33573807/faithfully-preserve-comments-in-parsed-xml-python-2-7
class CommentedTreeBuilder(ElementTree.TreeBuilder):
def __init__(self, *args, **kwargs):
@konifar
konifar / Activity.java
Created Nov 15, 2017
Change menu item icon color
View Activity.java
private void refreshMenuItem(@Nullable MenuItem menuItem) {
if (menuItem != null) {
Drawable drawable = ContextCompat.getDrawable(this, R.drawable.vec_ic_refresh_22);
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_ATOP);
DrawableCompat.setTint(drawable, ResourcesCompat.getColor(getResources(), R.color.grey600, null));
menuItem.setIcon(drawable);
}
}
@konifar
konifar / upload_sessions_to_firebase_database.dart
Created Jun 6, 2017
upload_sessions_to_firebase_database.dart
View upload_sessions_to_firebase_database.dart
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
main() async {
var response = await http.read(
'https://raw.githubusercontent.com/konifar/droidkaigi2016/master/app/src/main/res/raw/sessions_ja.json');
var json = {'ja': JSON.decode(response)};
@konifar
konifar / droidkaigi2017_sessions_ja.json
Created Jan 14, 2017
DroidKaig2017 sessions json sample
View droidkaigi2017_sessions_ja.json
[
{
"id": 1,
"title": "ウェルカムトーク",
"description": "",
"speaker": {
"id": 1,
"name": "mhidaka",
"image_url": "",
"twitter_name": "",
@konifar
konifar / gist:6809d1aae8cc79fb9523
Created Feb 28, 2016
Android localization CFP for English
View gist:6809d1aae8cc79fb9523
# Sammary
Many people think localization is diffecult. But actually it's just because they don't know what they have to do for localization. So I'm gonna talk about what and how we have to do for localization. For example, how to manage many strings.xml files, to implement plurals by languages, to apply Right-to-Left language.
If you will hear this talk, you become a localization master.
I'm developing Android app called Taptrip (https://play.google.com/store/apps/details?id=com.taptrip), 17 languages supports. And I developed DroidKaigi 2016 (The biggest Android conference in Tokyo) app (https://github.com/konifar/droidkaigi2016). It supports Japanese, English, Arabic, Korean. So I gonna talk by using these app as sample code.
# Detail
- How to manage many strings.xml files
- How to implement plural strings, diffrent time format
- How to implement Right-to-Left language text