Skip to content

Instantly share code, notes, and snippets.

View TakamiChie's full-sized avatar
:octocat:

高見知英 TakamiChie

:octocat:
View GitHub Profile
File file = /* 適当なFile(外部ストレージ上に保存している画像であること) */
ContentResolver cr = context.getContentResolver();
ContentValues cv = new ContentValues();
cv.put(MediaStore.Images.Media.TITLE, file.getName());
cv.put(MediaStore.Images.Media.DISPLAY_NAME, file.getName());
cv.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis());
cv.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
cv.put(MediaStore.Images.Media.DATA, file.getAbsolutePath());
Uri uri = cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, cv);
Bitmap thumbnail = $.getCachedImage(thumbnailUrl.toString());
$.id(R.id.image).image(url.toString(), false, false, 0, 0, thumbnail, 0);
@TakamiChie
TakamiChie / replacePicoCMS08to10.php
Created May 1, 2016 07:26
Pico0.8→1.0対応スクリプト
<?php
// set to Pico CMS root directory
require("lib/Pico.php");
class Replacer extends Pico
{
public function run(){
$this->loadConfig();
$files = $this->getFiles($this->getConfig("content_dir"), $this->getConfig("content_ext"));
foreach ($files as $file) {
// note用 プロパティ表示ツール
// noteの編集画面において、文字数や段落数、マークダウン記法版文章を表示します。
// ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level ADVANCED_OPTIMIZATIONS
// ==/ClosureCompiler==
(function() {
let nb = (document.getElementById("note-body") ||
document.querySelector("note-body div"));
@TakamiChie
TakamiChie / PPT2PDF.ps1
Created September 3, 2018 16:07
指定フォルダ配下のPowerPointファイルをすべてPDFに
# 指定フォルダ配下のPowerPointファイルを一括してPDFに変換します。
# PowerPoint自体を起動するので、動作に時間がかかります。
# 動作中はPCを操作しないことを推奨します
# また、共有などのトラブルが発生した場合はダイアログが表示され、処理が中断されますので、「動作中は離席しないこと」を推奨します
# 参考:https://blogs.technet.microsoft.com/stanabe/2008/12/10/windows-powershell-powerpoint-xps-pdf/
# 前準備
$ppapp = new-object -com powerpoint.application
$ppapp.visible = [Microsoft.Office.Core.MsoTriState]::MsoTrue
$ppfiles = Get-ChildItem -Recurse *.pptx
@TakamiChie
TakamiChie / maskCalendarSchedule.js
Created September 16, 2018 03:46
Googleカレンダーにて、特定の予定を「予定あり」として表示するワンライナー(開発者ツールで使う)
// Googleカレンダーのスクリーンショットをとって紹介するとき、一部のイベントを伏せたいとかありませんか?
// そういうときのためのスクリプトです。Googleカレンダーの月ビューを表示中、開発者ツールを表示してコンソールに打ち込むコマンドです。
// 下の/*隠したい予定のタイトルをここに入れる*/を隠したいイベントの名前に置き換えます。
document.querySelectorAll("div[data-eventchip]").forEach((n) => {d = n.querySelector("div > span > span:last-child"); if(d.textContent == /*隠したい予定のタイトルをここに入れる*/) d.textContent = "予定あり"; });
@TakamiChie
TakamiChie / main.py
Created November 27, 2018 13:19
文字列の各行に処理を行うPythonコードのひな型
# pythonのコンソールで使うと良いです。
s = """
ここに変換したいテキストを入力
"""
for n in s.split("\n"):
if n != "":
# ここに処理を入力
@TakamiChie
TakamiChie / main.py
Created November 27, 2018 15:48
文章中の時間表記をシフトするPythonコードのひな形
# あとで再利用可能な形にまとめるかも
# ex). 23:00→30分前を指定 22:30
import re
import math
s = """
ここに変換したい文章を入れる
"""
def timeshift(m):
t = int(m.group(1)) * 60 + int(m.group(2))
t -= 0 # ここでタイムシフトしたい時間(分)を指定する
@TakamiChie
TakamiChie / Zaim Add Checkbox.js
Last active December 13, 2018 04:47
Zaimの日ごとの履歴一覧画面にチェックボックスを表示する(するだけ)
// Zaimの日ごとの履歴一覧画面にチェックボックスを表示するBookmarklet
// 日ごとの履歴一覧を表示した状態で、ブックマークレットを実行してください。
// 下記サイトでコンパイル可能です。
// https://closure-compiler.appspot.com/
// ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level SIMPLE_OPTIMIZATIONS
// ==/ClosureCompiler==
javascript:(function(){
let table = document.querySelector("#main .list");
@TakamiChie
TakamiChie / Copy.js
Created December 14, 2018 18:16
Microsoft To-DoのWeb UIにおいて、開いているタスクリストのタスクをコピーする
// https://to-do.office.com/today あたりで開発者モードを開きコンソールで実行する
var s = "";
document.querySelectorAll(".taskItem-title").forEach((e) => {
s += e.textContent + "\n";
});
prompt("CopyThis", s);