Skip to content

Instantly share code, notes, and snippets.

View sonsongithub's full-sized avatar

Yuichi Yoshida sonsongithub

View GitHub Profile
@sonsongithub
sonsongithub / main.cpp
Created October 14, 2018 03:18
sample for clang++
#include<stdio.h>
int main(void) {
printf("Hello C world");
return 0;
}
@sonsongithub
sonsongithub / gist:e476024204be381c6b1bb79996a42477
Created June 18, 2018 09:41
日本語を含む Keynote を slideshare にアップロードする
# https://abicky.net/2016/05/16/033103/ より
LANG=C LC_ALL=C sed -i '' s'|/Registry (Adobe) /Ordering (Japan1) /Supplement [0-9]|/Registry(Adobe) /Ordering(Identity) /Supplement 0|g' /path/to/pdf
@sonsongithub
sonsongithub / exclude.swift
Created May 15, 2018 11:22
How to exclude Notes and Reminders apps from the UIActivityViewController?
let activityController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
activityController.excludedActivityTypes = [
UIActivityType.assignToContact,
UIActivityType.print,
UIActivityType.addToReadingList,
UIActivityType.saveToCameraRoll,
UIActivityType.openInIBooks,
UIActivityType(rawValue: "com.apple.reminders.RemindersEditorExtension"),
UIActivityType(rawValue: "com.apple.mobilenotes.SharingExtension"),
]
@sonsongithub
sonsongithub / extract_userdefault_key.rb
Created May 14, 2018 02:30
swiftファイルからNSLocalizedStringを抜き出すスクリプト
require 'xcodeproj'
project_path = '~/hoge.xcodeproj'
project = Xcodeproj::Project.open(project_path)
puts project
target = project.targets.first
files = target.source_build_phase.files.to_a.map do |pbx_build_file|
pbx_build_file.file_ref.real_path.to_s
end
@sonsongithub
sonsongithub / setting.json
Created May 6, 2018 23:06
Visual Studio Codeで日本語のTeXをコンパイルするための設定
{
"latex-workshop.latex.tools": [
{
"command": "platex",
"args": [
"-synctex=1",
"-jobname=\"%DOCFILE%\"",
"-kanji=utf8",
"-guess-input-enc",
"%DOCFILE%.tex"
@sonsongithub
sonsongithub / amazon_parser.rb
Created December 25, 2017 08:29
amazon_parser.rb
fr = File.open("./booklist.txt", "r")
text = fr.read
a = text.scan(/注文の詳細注文日: (\d+)年(\d+)月(\d+)日.+\n(.+?)\n(.+?)\n販売: (.+?)\n/)
a.each{|e|
title = e[3].gsub("(Kindle 書籍 Kindle Books)", "")
year = e[0].to_i
month = e[1].to_i
day = e[2].to_i
@sonsongithub
sonsongithub / onigiri.sol
Created October 4, 2017 10:48
コントラクトのコード
pragma solidity ^0.4.13;
contract Onigiri {
// contructのオーナー?
address owner;
// おにぎりの残数
uint public remains;
// おにぎりの単価
uint constant price = 10;
// 購入する顧客
@sonsongithub
sonsongithub / tunefind.rb
Created October 1, 2017 23:54
Get songs list from tunefind.
def getHTML(url)
begin
uri = URI.parse(url)
response = Net::HTTP.start(uri.host, uri.port) do |http|
http.open_timeout = 15
http.read_timeout = 15
http.get(uri.request_uri)
end
return response.body
rescue => e
gpg --list-secret-keys --keyid-format LONG
gpg --armor --export <ID>
@sonsongithub
sonsongithub / ml.swift
Created September 18, 2017 02:41
How to update Core ML model with a file in Document directory.
do {
// You have to add the file whose name is changed from KerasMNIST.mlmodel to KerasMNIST.bin to app target.
// In order to avoid that Xcode compiles a mlmodel file automatcally.
guard let url = Bundle.main.url(forResource: "KerasMNIST", withExtension: "bin") else { return }
let compiledURL = try MLModel.compileModel(at: url)
print(compiledURL)
let model = try MLModel(contentsOf: compiledURL)
print(model)
} catch {
print(error)