Skip to content

Instantly share code, notes, and snippets.

View ikesyo's full-sized avatar
🏠
Working from home

IKEDA Sho ikesyo

🏠
Working from home
View GitHub Profile
@johndevs
johndevs / get-all-files.gql
Last active March 19, 2022 20:54
Github GraphQL - Get all file contents in repository
# Provide $query as a variable.
# The query is the same as you would enter into the search field e.g. "org:johndevs in:name feedreader"
query GetFilesQuery($branch: GitObjectID, $query: String!) {
search(first: 1, type: REPOSITORY, query: $query) {
edges {
node {
... on Repository {
object(expression: "master:", oid: $branch) {
... on Tree {
@marty-suzuki
marty-suzuki / UnidirectionalInputOutputViewModelWithKeyPath.swift
Last active March 28, 2019 09:43
Logic of Unidirectional Input / Output ViewModel Sample with Swift KeyPath (Sample logic of https://github.com/cats-oss/Unio)
// This sample works on Swift4.2 and Swift5!
// Let's try to execute this sample with Playground!
import Foundation
// - MARK: Artificially RxSwift classes
public enum Rx {
public final class Observable<E> {}

Open Source Swift

Nicholas Maccharoli

github.com/nirma

@din0sr


@smileyborg
smileyborg / InteractiveTransitionCollectionViewDeselection.m
Last active January 15, 2023 13:03
Animate table & collection view deselection alongside interactive transition (for iOS 11 and later)
// UICollectionView Objective-C example
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSIndexPath *selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] firstObject];
if (selectedIndexPath != nil) {
id<UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
if (coordinator != nil) {
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
@koyachi
koyachi / introducing-mint.md
Created December 9, 2017 05:35
Swift Package Managerを使って作成したコマンドをMintでインストールする

Swift Package Managerを使って作成したコマンドをMintでインストールする

[Mint][1]はSwift Package Managerで作成したコマンドラインツールのインストール、実行、配布を簡単にすることを目的としたツールです。 Homebrewでのformula管理の煩わしさの無さ、同一コマンドをバージョン指定で実行可能というところが売りのようです。

ここでは簡単なコマンドラインツールをSwift Package Managerで作成し、Mintで実行する流れを確認します。 SPMでCLIツールを作る手順を既に知ってる場合は「Mintをインストール」から確認するとよいでしょう。

@SeanSobey
SeanSobey / .gitattributes
Last active November 4, 2022 08:57
Git to diff zip (or any compressed) files. See this (https://tante.cc/2010/06/23/managing-zip-based-file-formats-in-git/) article.
*.[7z,xz,bzip2,gzip,tar,zip,wim,ar,arj,cab,chm,cpio,cramfs,dmg,ext,fat,gpt,hfs,ihex,iso,lzh,lzma,mbr,.msi,nsis,ntfs,qcow2,rar,rpm,squashfs,udf,uefi,vdi,vhd,vmdk,wim,xar,z] diff=archive
@mayoff
mayoff / convert.swift
Last active June 16, 2021 23:07
How to convert from DispatchData to Data without copying the bytes
import Dispatch
import Foundation
var x = 7
let dd = withUnsafeBytes(of: &x, { DispatchData.init(bytes: $0) })
print(dd as? Data) // Case 1: nil
print(dd as? NSData) // Case 2: nil
print(dd as Any as? Data) // Case 3: nil
print(dd as Any as? NSData) // Case 4: .some
print(dd as Any as? NSData as Data?) // Case 5: .some
@lattner
lattner / TaskConcurrencyManifesto.md
Last active May 3, 2024 08:18
Swift Concurrency Manifesto
@inamiy
inamiy / reactiveswift.swift
Last active July 27, 2017 17:06
Rx "Hot -> Cold" + multiple subscription behavior
print("=== signal (hot) ===")
do {
let (signal, observer) = Signal<Int, NoError>.pipe()
let s = signal
.map { x -> Int in
print("map \(x)")
return x
}
s.observeValues { _ in }
@lattner
lattner / async_swift_proposal.md
Last active April 21, 2024 09:43 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.