Skip to content

Instantly share code, notes, and snippets.

@fumiyasac
fumiyasac / ArticleViewController.swift
Last active December 3, 2020 16:43
ライブラリなしでメディアアプリでよく見る無限スクロールするタブの動きを実装したUIサンプルの紹介 ref: https://qiita.com/fumiyasac@github/items/af4fed8ea4d0b94e6bc4
class ArticleViewController: UIViewController {
// カテゴリーの一覧データ
private let categoryList: [String] = ArticleMock.getArticleCategories()
// 現在表示しているViewControllerのタグ番号
private var currentCategoryIndex: Int = 0
// ページングして表示させるViewControllerを保持する配列
private var targetViewControllerLists: [UIViewController] = []
@okapies
okapies / mastodon-client.md
Last active October 3, 2023 10:18
Mastodon API の叩き方

Mastodon の API を叩くには以下の手順を踏む必要がある:

  1. OAuth2 クライアントを登録する
  2. アクセストークンを取得する
  3. アクセストークンを Authorization ヘッダに指定して API にアクセスする

OAuth2 クライアント登録

Mastodon の Apps API に登録情報を送ってクライアントを払い出してもらう(一度だけやれば OK).

@y-takagi
y-takagi / DOCUMENT.md
Last active April 29, 2024 16:36
iOSでデータを永続化する方法

How to save data in iOS

この投稿では、iOSのファイルシステムについて理解し、データを永続化(iCloud含む)する方法を紹介する。尚、サンプルコードは動かない可能性もあるので参考程度にして下さい。

iOS File System

アプリがファイルシステムとやり取り出来る場所は、ほぼアプリのサンドボックス内のディレクトリに制限されている。新しいアプリがインストールされる際、インストーラーはサンドボックス内に複数のコンテナを作成し、図1に示す構成をとる。各コンテナには役割があり、Bundle Containerはアプリのバンドルを保持し、Data Containerはアプリとユーザ両方のデータを保持する。Data Containerは用途毎に、さらに複数のディレクトリに分けられる。アプリは、例えばiCloud Containerのように、実行時に追加のコンテナへのアクセスをリクエストすることもある。

IMG_0017_RESIZE.png

図1. An iOS app operating within its own sandbox

@cucmberium
cucmberium / gist:8ca7f4a5c5ea5a8b6590
Last active May 11, 2019 16:40
Twitter poll api

twitterの投票

コード

var status = await tokens.Statuses.ShowAsync(id => 696716686381027328, include_cards => true, cards_platform => "Android-12");

https://api.twitter.com/1.1/statuses/show.json?id=696716686381027328&include_cards=true&cards_platform=Android-12

Twitter for AndroidのCK/CS

public class FontFitViewHolder extends RecyclerView.ViewHolder {
private final FontFitViewHolder self = this;
private Handler mHandler;
public BandCheckViewHolder(View v, int height) {
super(v);
mCardView = (CardView)itemView;
mTextView = (MultiLineEllipsizeTextView) v.findViewById(R.id.viewholder_fontfit_card);
}
@ivanyv
ivanyv / application.amp.erb
Created December 12, 2015 02:51
Easy Google AMP on Rails
<html>
<head>
<link rel="canonical" href="<%= current_uri_sans_amp %>">
</head>
...
</html>
@slavafomin
slavafomin / 0-readme.md
Last active April 4, 2020 04:29
Loop promises in Angular.js / Run list of actions sequantually

The provided example will allow you to do sequential requests to the server in Angular.js.

It will iterate all the items and call server for each item, however, if one request will fail, all sequential requests will be aborted.

If you need to call all requests no matter what, just replace promise.then() with promise.finally().

Cheers!

@kaiinui
kaiinui / eventbus.md
Last active March 3, 2017 03:54
Android開発いろいろ

EventBus

EventBus は必ず onStart()onStop() で呼ぶ。バックグラウンドで色々動かれて困る。 また、onStop() では super.onStop() よりも 先に 呼ぶ。

@Override
protected void onStart() {
 super.onStart();
package com.example.fragmentpageradapterdemo;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.ListFragment;
import android.support.v4.view.ViewPager;
import android.util.Log;
@okamuuu
okamuuu / mongo.aggregate.coffee
Last active September 8, 2016 16:06
mongo aggregate order by ymd
require 'coffee-script'
require 'coffee-errors'
assert = require 'assert'
moment = require 'moment'
async = require 'async'
MongoClient = require('mongodb').MongoClient
describe 'MongoClient', ->