Skip to content

Instantly share code, notes, and snippets.

@nakiwo
nakiwo / combine_retry.swift
Created August 27, 2020 13:51
combine_retry
import Combine
import Foundation
enum CustomError: Error {
case retryError
case otherError
}
var count = 0
@nakiwo
nakiwo / podcast_to_csv.rb
Created January 19, 2020 11:48
podcast_to_csv.rb
require 'rss'
require "csv"
rss_source = File.new('feed.xml')
rss = RSS::Parser.parse(rss_source, false)
CSV.open('test.csv','w') do |csv|
rss.items.each do |item|
title = item.title
date = item.pubDate.localtime.strftime('%Y/%m/%d')
@nakiwo
nakiwo / MyButton.swift
Created October 6, 2017 14:10
関連づけられたラベルの色をステートに合わせて変えるUIButton。ハイライト時のフェードアニメーション付き
import UIKit
class MyButton: UIButton {
@IBOutlet weak var associatedLabel: UILabel? {
didSet {
associatedLabel?.textColor = currentTitleColor
}
}
// Swift 3
import UIKit
class TestViewController: UIViewController {
var text: String!
static func create(with text: String) -> Self {
let vc = instantiateFromStoryboard()
@nakiwo
nakiwo / gist:afc59f05147d9526d7d5
Created March 25, 2015 03:05
dump mobileprovision as text
openssl asn1parse -inform DER -in foo.mobileprovision
@nakiwo
nakiwo / gist:c7c8d56cfb1c64c8617e
Created August 19, 2014 02:19
embedded.mobileprovisionにあるplistを取得
- (NSDictionary *)embeddedMobileprovisionPlist
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"];
if (!path) {
return nil;
}
NSData *profileData = [NSData dataWithContentsOfFile:path];
if (!profileData) {
return nil;
@nakiwo
nakiwo / gist:e5e28124afbe4d32b490
Last active August 29, 2015 14:02
SSID取得
@import SystemConfiguration;
#import <SystemConfiguration/CaptiveNetwork.h>
- (NSString *)currentSSID
{
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
if (!interfaceNames.count) {
return nil;
}
@nakiwo
nakiwo / isEqual
Last active August 29, 2015 13:56
BOOL isEqual(NSObject *a, NSObject *b)
{
if (a) {
if (b) {
return [a isEqual:b];
}
} else { // a == nil
if (!b) {
return YES;
}
@nakiwo
nakiwo / gist:5500639
Created May 2, 2013 07:14
rubycocoaでplist生成
require 'osx/cocoa'
data = OSX::NSPropertyListSerialization.dataWithPropertyList_format_options_error_(obj, OSX::NSPropertyListBinaryFormat_v1_0, 0, nil)
data.writeToFile_atomically_(path, true)