Skip to content

Instantly share code, notes, and snippets.

View hmhmsh's full-sized avatar

shunkun hmhmsh

View GitHub Profile
@josh-burton
josh-burton / MergeRecyclerAdapter
Created August 26, 2014 20:38
A Merge Adapter for the RecyclerView. Based on CommonsWare cwac-merge and the MergedAdapter in the android sdk.
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
@hecomi
hecomi / Detector.cs
Last active April 9, 2022 14:18
図形を認識するヤツ
/*
The MIT License (MIT)
Copyright (c) 2014 hecomi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@kawanet
kawanet / string_to_buffer.js
Last active May 16, 2024 10:35
String と ArrayBuffer の相互変換 JavaScript
// 文字列から ArrayBuffer への変換
function string_to_buffer(src) {
return (new Uint16Array([].map.call(src, function(c) {
return c.charCodeAt(0)
}))).buffer;
}
// ArrayBuffer から文字列への変換
@AliSoftware
AliSoftware / Coordinator.swift
Last active July 10, 2022 14:32
Coordinators & StateMachine - Concept
struct Coordinator {
let window: UIWindow
let navCtrl: UINavigationController?
func start() {
presentWelcomeScreen()
}
private func presentWelcomeScreen() {
let vc = WelcomeScreenViewController() // Instanciate from code, XIB, Storyboard, whatever your jam is
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
import Foundation
enum PPAP {
case Start
indirect case Pen(PPAP), Apple(PPAP), Pineapple(PPAP), Finish(PPAP)
var output: String {
switch self {
case .Start: return "ピッピッピコ ピコ太郎〜♪"
case .Pen(let p): return "\(p.output)\nI have a ✏️"
case .Apple(let p): return "\(p.output)\nI have an 🍎"
@kakajika
kakajika / Brainf_ck.kt
Last active December 5, 2016 11:23
A simple customizable Brainf*ck implementation in Kotlin.
import java.io.File
import java.io.InputStream
import java.io.OutputStream
import java.io.Reader
enum class Token {
NEXT, PREV, INC, DEC, GET, PUT, LOOP, JUMP, ROOT
}
interface Parser {
@lattner
lattner / TaskConcurrencyManifesto.md
Last active July 25, 2024 06:14
Swift Concurrency Manifesto
@mono0926
mono0926 / 1Database.swift
Last active June 2, 2022 08:15
FirestoreのRxSwiftとの組み合わせ。Codableも活用。 [追記] FirestoreのデータはCodable非対応のプロパティを持ててしまいそれが含まれると対応難しいのでCodableは捨てた方が良いかもしれない
//
// Database.swift
// Model
//
// Created by mono on 2017/10/14.
// Copyright © 2017 Masayuki Ono All rights reserved.
//
import Foundation
import FirebaseCore
extension String {
func split(_ size: Int) -> [String] {
return stride(from: 0, to: self.count, by: size).map { i -> String in
let startIndex = self.index(self.startIndex, offsetBy: i)
let endIndex = self.index(startIndex, offsetBy: size, limitedBy: self.endIndex) ?? self.endIndex
return String(self[startIndex..<endIndex])
}
}
}
print("あけましておめでとうございます。今年もどうぞよろしくお願いします。".split(5))