Skip to content

Instantly share code, notes, and snippets.

@tad-iizuka
tad-iizuka / emojiToImage
Created October 20, 2017 03:14
Emoji convert to UIImage. Swift 4
func emojiToImage(text: String, size: CGFloat) -> UIImage {
let outputImageSize = CGSize.init(width: size, height: size)
let baseSize = text.boundingRect(with: CGSize(width: 2048, height: 2048),
options: .usesLineFragmentOrigin,
attributes: [.font: UIFont.systemFont(ofSize: size / 2)], context: nil).size
let fontSize = outputImageSize.width / max(baseSize.width, baseSize.height) * (outputImageSize.width / 2)
let font = UIFont.systemFont(ofSize: fontSize)
let textSize = text.boundingRect(with: CGSize(width: outputImageSize.width, height: outputImageSize.height),
options: .usesLineFragmentOrigin,
@tad-iizuka
tad-iizuka / ViewController.swift
Created October 13, 2017 02:39
MP3 Recording with lame and AVAudioEngine, Swift 4
//
// ViewController.swift
// MP3RecordingSample
//
// Created by Tadashi on 2017/10/13.
// Copyright © 2017 UBUNIFU Inc. All rights reserved.
//
import UIKit
import AVFoundation
import AudioToolbox
@tad-iizuka
tad-iizuka / ViewController.swift
Created October 2, 2017 06:27
Crush when processing .jpegRepresentation
//
// ViewController.swift
// CoreImageDebug
//
// Created by Tadashi on 2017/10/02.
// Copyright © 2017 UBUNIFU Inc. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@tad-iizuka
tad-iizuka / GLKView
Created September 27, 2017 04:53
GLKView delegate
func glkView(_ view: GLKView, drawIn rect: CGRect) {
if isSimulator() {
return
}
let start = NSDate()
glClearColor(0.0, 0.0, 0.0, 1.0)
glClear(GLbitfield(GL_COLOR_BUFFER_BIT))
@tad-iizuka
tad-iizuka / ViewController.swift
Last active November 7, 2022 16:43
Photo Capture Sample Swift 4 + iOS 11
//
// ViewController.swift
// PhotoCaptureSample
//
// Created by Tadashi on 2017/09/23.
// Copyright © 2017 UBUNIFU Incorporated. All rights reserved.
//
import UIKit
import AVFoundation
import Photos
@tad-iizuka
tad-iizuka / ViewController.swift
Created September 14, 2017 06:00
NSOperationSample
//
// ViewController.swift
// NSOperationSample
//
// Created by Tadashi on 2017/09/13.
// Copyright © 2017 UBUNIFU Incorporated. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@tad-iizuka
tad-iizuka / gist:1e90e78be04526a7571839441b464d44
Created July 4, 2017 05:01
Blending two DNG Images by using Core Image
//
// ViewController.swift
// CoreImageBlendSample
//
// Created by Tadashi on 2017/07/04.
// Copyright © 2017 UBUNIFU Incorporated. All rights reserved.
//
import UIKit
@tad-iizuka
tad-iizuka / gist:f6c6cb6e2d3cea71a44ce7fe395e5913
Created June 30, 2017 03:29
Blending two images by using GPUImage 2
let alphaBlend = AlphaBlend()
alphaBlend.mix = 0.5
let input1 = PictureInput(image: UIImage.init(named: "IMAGE1.jpg")!)
let input2 = PictureInput(image: UIImage.init(named: "IMAGE2.jpg")!)
let output = PictureOutput()
output.imageAvailableCallback = {image in
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
}
input1 --> alphaBlend
UIView.setAnimationsEnabled(false)
button.setTitle("label", for: .normal)
button.layoutIfNeeded()
UIView.setAnimationsEnabled(true)
import requests
import json
import os
HEADER = {
'Content-type': 'application/json',
'Authorization': 'Bearer ' + 'Channel Access Token'
}
def lambda_handler(event, context):