Skip to content

Instantly share code, notes, and snippets.

@Arime9
Arime9 / PhotosAlbum.m
Last active April 9, 2024 07:08
Implementation of UIImageWriteToSavedPhotosAlbum in the Cordova plugin.
#import "PhotosAlbum.h"
#import <Cordova/CDV.h>
@implementation PhotosAlbum
- (void)saveImageToPhotosAlbum:(CDVInvokedUrlCommand *)command {
[self.commandDelegate runInBackground : ^{
NSString *base64String = [command.arguments objectAtIndex:0];
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:base64String options:0];
UIImage *image = [UIImage imageWithData:imageData];
@Arime9
Arime9 / View+Screenshot.swift
Last active November 16, 2022 08:17
View to UIImage - Swift code
import SwiftUI
extension View {
@MainActor public func screenshot(scale: CGFloat = 1.0) -> UIImage? {
if #available(iOS 16.0, *) {
// ImageRendererの方が処理速度が早く、画像が高精細
let renderer = ImageRenderer(content: self)
renderer.scale = scale
renderer.isOpaque = true
return renderer.uiImage
<style>
table td {
background: #eee;
}
table tr:nth-child(even) td {
background: #fff;
}
table tr:first-child td {
background: #0ff;
}
# Dir class
if Dir.exist?(bitcode_symbol_map_path)
# do something
end
Dir.chdir("..") do
# do something
end
@Arime9
Arime9 / exit-if-needed.sh
Last active February 12, 2020 06:27
Bash Pocket Reference
#!/bin/bash
# Case 1
# 実行結果を受け取り、失敗系のときは echo で出力する
set -e
# Anything
set +e
echo '$' "bundle install"
@Arime9
Arime9 / install-binaries-on-macos
Last active August 15, 2023 02:16
install binaries - .bash_profile
==== bash ====
# bash #
## Setiing PATH ##
$ echo '''
# bash''' >> ~/.bash_profile
$ echo 'export BASH_SILENCE_DEPRECATION_WARNING=1' >> ~/.bash_profile
@Arime9
Arime9 / LinkTextViewDelegateRepresents.swift
Last active January 24, 2019 06:27
【Swift+Extension】UITextViewで、ハイパーリンクに対応する ref: https://qiita.com/Arime/items/d9f679b13921a8bfe515
import UIKit
final class LinkTextViewDelegateRepresents: NSObject {
typealias Action = (_ textView: UITextView, _ url: URL, _ characterRange: NSRange, _ interaction: UITextItemInteraction) -> Bool
var action: Action
init(action: @escaping Action) {
self.action = action
@Arime9
Arime9 / String+Range.swift
Last active January 24, 2019 06:23
【Swift+Extension】UILabelで、一部の文字だけ色を付ける ref: https://qiita.com/Arime/items/5ede5f9423a205cf2deb
import Foundation
extension String {
func nsRange(from range: Range<String.Index>) -> NSRange {
return NSRange(range, in: self)
}
func ranges(of searchString: String, options mask: NSString.CompareOptions = [], locale: Locale? = nil) -> [Range<String.Index>] {
var ranges: [Range<String.Index>] = []
#! /usr/bin/env ruby
# encoding: UTF-8
require 'uri'
require 'json'
require 'open-uri'
require 'openssl'
require 'nokogiri'
def get_documents_info()