Skip to content

Instantly share code, notes, and snippets.

View 9bany's full-sized avatar
🏠
Working from home

Bany 9bany

🏠
Working from home
View GitHub Profile
@9bany
9bany / build_carthage_xcode_12.sh
Last active December 6, 2020 16:08
Shell script file: fix carthage build framework error with xcode 12
#!/usr/bin/env bash
# carthage.sh
set -euo pipefail
xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
trap 'rm -f "$xcconfig"' INT TERM HUP EXIT
echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200 = arm64 arm64e armv7 armv7s armv6 armv8' >> $xcconfig
@9bany
9bany / Podfile
Last active December 16, 2020 07:01
Cocoa rome: Build podfile
platform :ios, '10.0'
use_frameworks!
plugin 'cocoapods-rome',
:pre_compile => Proc.new { |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.0'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
@9bany
9bany / gist:2237dc2081aa42eb053baaf6e4151162
Last active March 24, 2021 11:59
Use UIViewController as UICollectionViewCell
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: EmtyCell.name, for: indexPath)
var viewController = YourViewController()
cell.contentView.addSubview(viewController.view)
viewController.view.translatesAutoresizingMaskIntoConstraints = false
@9bany
9bany / requestClosure.swift
Created December 21, 2020 10:55
RequestClosure change url before call api in moya
let requestClosure = { (endpoint: Endpoint, done: MoyaProvider.RequestResultClosure) in
do {
let queryItemToken = URLQueryItem(name: "key", value: "value")
var request = try endpoint.urlRequest()
var url = request.url
request.url = URL.addQueryParams(url: url!, newParams: [queryItemToken])!
@9bany
9bany / run.sh
Created March 24, 2021 13:36
script upload
#!/usr/bin/env bash
IPAFile=`find . -name *.ipa | head -1`
npm install -g appcenter-cli
appcenter login --token [login token]
appcenter distribute release -f $IPAFile -g Collaborators --app Punday/mondaypundayapp--ios
@9bany
9bany / run.sh
Last active March 31, 2021 10:44
Delete all xcode items
#!/bin/sh
rm -rf /Applications/Xcode.app
rm -rf /Library/Preferences/com.apple.dt.Xcode.plist
rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist
rm -rf ~/Library/Caches/com.apple.dt.Xcode
rm -rf ~/Library/Application Support/Xcode
rm -rf ~/Library/Developer/Xcode
rm -rf ~/Library/Developer/CoreSimulator
@9bany
9bany / UIActionReturnTextField.swift
Created April 13, 2021 09:08
Add return keys UITextField
class UIActionReturnTextField: UITextField {
func addDoneCancelToolbar(onDone: (target: Any, action: Selector)? = nil, onCancel: (target: Any, action: Selector)? = nil) {
let onCancel = onCancel ?? (target: self, action: #selector(cancelButtonTapped))
let onDone = onDone ?? (target: self, action: #selector(doneButtonTapped))
let toolbar: UIToolbar = UIToolbar()
toolbar.barStyle = .default
toolbar.items = [
UIBarButtonItem(title: "Cancel", style: .plain, target: onCancel.target, action: onCancel.action),
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil),
@9bany
9bany / Stack.swift
Created April 18, 2021 12:18
Stack structure in Swift
struct Stack<T>: CustomStringConvertible {
var description: String {
let title = "==== Stack ==== \n"
let body = self.array.map{ "\($0)" }.reversed().joined(separator: "\n")
let end = "\n==============="
return title + body + end
}
private var array: [T] = []
@9bany
9bany / layout.dart
Created April 21, 2021 07:38
Some layout in flutter
Widget PlayerConnectWidget(double width,double height){
return SingleChildScrollView(
child: Container(
margin: EdgeInsets.only(left: width*0.03,right: width*0.03,top: width*0.05),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
@9bany
9bany / git_push.sh
Created June 9, 2021 15:54
git_push auto script file
parse_git_branch() {
git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3
}
git push origin $(parse_git_branch)