Skip to content

Instantly share code, notes, and snippets.

Shinichiro Aska s-aska

View GitHub Profile
View TwitterText.swift
class TwitterText {
// swiftlint:disable:next force_try
static let linkDetector = try! NSDataDetector(types: NSTextCheckingType.Link.rawValue)
class func count(text: String, hasImage: Bool) -> Int {
let textLength = text.characters.count // 🍣 is 1
let objcLength = text.utf16.count // 🍣 is 2
let objcText = text as NSString
let objcRange = NSRange(location: 0, length: objcLength)
View SFSafariViewController-memo.md

問題

SFSafariViewController内のShareボタンからShare Extensionを起動するとページタイトルが取得できない。

Safari

SFSafariViewController

@s-aska
s-aska / ogp.js
Created Apr 26, 2016
OGP Fetch API for AWS Lambda
View ogp.js
'use strict';
console.log('Loading function');
const http = require('http');
const https = require('https');
const regexs = [
new RegExp('<meta property=["\']og:title["\'] content=["\']([^>]+)["\']', 'i'),
new RegExp('<meta content=["\']([^>]+)["\'] property=["\']og:title["\']', 'i'),
new RegExp('<title>([^<]*)</title>', 'i'),
];
@s-aska
s-aska / longurl.go
Created Mar 3, 2016
🔫 Don't redirect !!!
View longurl.go
package main
import(
"errors"
"fmt"
"net/http"
)
var RedirectAttemptedError = errors.New("redirect")
var nopasteClient = func() (*http.Client) {
View carthage.sh
#!/bin/bash
# exit if a command fails
set -e
echo ""
echo "-----------------------"
echo "Installing dependencies"
echo "-----------------------"
# Homebrew
View How-to-use-Developer-Tools.md

Developer Toolsの使い方

  1. http://justaway.info/ を Google Chrome で開く
  2. 適当なところを右クリックして「要素の検証」を選択
  3. 「Developer Tools」というウィンドウが立ち上がる、「Console」というタブを選択
  4. 🚫の下の「> 」となっている部分の少し右をクリックし、以下のコードをペーストしEnterキーを叩く(この時画面をよく見ておいて下さい)
$('img').animate({top: '-1000px'})
@s-aska
s-aska / GoogleChrome.swift
Created May 18, 2015
任意のURLをブラウザ(Chrome)で開いた際に遷移元アプリに戻る導線を付ける
View GoogleChrome.swift
//
// GoogleChrome.swift
// Justaway
//
// Created by Shinichiro Aska on 5/18/15.
// Copyright (c) 2015 Shinichiro Aska. All rights reserved.
//
import UIKit
View TwitterVia.swift
import Foundation
import SwifteriOS
struct TwitterVia {
let name: String
let URL: NSURL?
struct Static {
static let regexp = NSRegularExpression(pattern: "<a href=\"(.+)\" rel=\"nofollow\">(.+)</a>", options: NSRegularExpressionOptions(0), error: nil)!
}
@s-aska
s-aska / Notification.swift
Last active Dec 5, 2015
NSNotificationCenterのラッパー
View Notification.swift
import Foundation
class Notification {
// MARK: - Singleton
struct Static {
static let instance = Notification()
static let queue = dispatch_queue_create("Notification.Static.instance.cache", DISPATCH_QUEUE_SERIAL)
}
You can’t perform that action at this time.