Skip to content

Instantly share code, notes, and snippets.

View benjaminhorner's full-sized avatar
:octocat:
Available for hire

Benjamin Horner benjaminhorner

:octocat:
Available for hire
View GitHub Profile
@SankethBK
SankethBK / main.dart
Last active September 30, 2022 18:53
Gmail scroll button animation
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(const GmailComposeButton());
}
class GmailComposeButton extends StatefulWidget {
@pichillilorenzo
pichillilorenzo / InAppWebViewPopupWindowExample.dart
Created June 30, 2020 15:21
InAppWebView - Popup Window Example
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(new MyApp());
}
class MyApp extends StatefulWidget {
@nRewik
nRewik / UILabel+FontSize.Swift
Last active April 22, 2024 20:49
iOS-Swift adjust font size to fit in rect
//
// UILabel+FontSize.Swift
//
// Created by Nutchaphon Rewik on 7/11/15.
// Copyright (c) 2015 Nutchaphon Rewik. All rights reserved.
//
import UIKit
extension UILabel{
@benjaminhorner
benjaminhorner / ScrollTextFieldAboveKeyboard
Last active May 31, 2022 12:21
Scroll UITextField above Keyboard in a UITableView OR UIScrollView in Swift
func keyboardWillShow(notification: NSNotification) {
if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
let contentInsets = UIEdgeInsets(top: self.tableView.contentInset.top, left: 0, bottom: keyboardSize.height, right: 0)
self.tableView.contentInset = contentInsets
// If active text field is hidden by keyboard, scroll it so it's visible
// Your app might not need or want this behavior.
var aRect: CGRect = self.view.frame
aRect.size.height -= keyboardSize.height
let activeTextFieldRect: CGRect?
@alexcristea
alexcristea / install-manifest.plist
Last active January 31, 2023 11:53
Over-the-Air Ad Hoc Distribution manifest for iOS8. More about this subject you can find on http://www.informit.com/articles/article.aspx?p=1829415&seqNum=16
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- array of downloads. -->
<key>items</key>
<array>
<dict>
<!-- an array of assets to download -->
@finder39
finder39 / Swift-MD5.swift
Last active March 20, 2018 13:37
Swift MD5
extension String {
func md5() -> String! {
let str = self.cStringUsingEncoding(NSUTF8StringEncoding)
let strLen = CUnsignedInt(self.lengthOfBytesUsingEncoding(NSUTF8StringEncoding))
let digestLen = Int(CC_MD5_DIGEST_LENGTH)
let result = UnsafeMutablePointer<CUnsignedChar>.alloc(digestLen)
CC_MD5(str!, strLen, result)
var hash = NSMutableString()
@kazu69
kazu69 / ViewController.swift
Created July 6, 2014 10:24
swift UIActionSheet sample
//
// ViewController.swift
//
import UIKit
class ViewController: UIViewController, UIActionSheetDelegate {
@IBAction func tapButton(sender : AnyObject) {
var sheet: UIActionSheet = UIActionSheet();
let title: String = "Please choose a course";
@sawapi
sawapi / AppDelegate.swift
Last active October 25, 2023 09:26
[Swift] Push Notification
//
// AppDelegate.swift
// pushtest
//
// Created by sawapi on 2014/06/08.
// Copyright (c) 2014年 sawapi. All rights reserved.
//
// iOS8用
import UIKit
@johnhatvani
johnhatvani / Dates.playground
Last active March 15, 2023 10:12
Swift Playground #1 adding components to Date using operator overloading.
import Foundation
extension Int{
var day: (Int, Calendar.Component) {
return (self, .day)
}
var month: (Int, Calendar.Component) {
return (self, .month)
}
@jquave
jquave / SwiftTable
Created June 2, 2014 20:58
Example code for Table View in Swift
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {