Skip to content

Instantly share code, notes, and snippets.

View damozhang's full-sized avatar
🏠
Working from home

Wei damozhang

🏠
Working from home
  • California
View GitHub Profile
@import Photos;
[PHPhotoLibrary requestAuthorizationForAccessLevel:PHAccessLevelReadWrite handler:^(PHAuthorizationStatus status) {
NSLog(@"PHAuthorizationStatus: %ld", status);
PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init];
fetchOptions.includeHiddenAssets = YES;
fetchOptions.includeAllBurstAssets = YES;
PHFetchResult<PHAsset *> *result = [PHAsset fetchAssetsWithOptions:fetchOptions];
@DejanEnspyra
DejanEnspyra / CameraHandler.swift
Last active September 12, 2023 11:00
Access iOS Camera and Photo Library with Swift 3. http://theappspace.com/swift-access-ios-camera-photo-library/
//
// CameraHandler.swift
// theappspace.com
//
// Created by Dejan Atanasov on 26/06/2017.
// Copyright © 2017 Dejan Atanasov. All rights reserved.
//
import Foundation
import UIKit
@sttz
sttz / AndroidKeystoreAuthenticator.cs
Created June 15, 2017 16:16
Unity editor script that stores Android Keystore passwords in the macOS Keychain.
using System;
using System.IO;
using UnityEditor;
using UnityEditor.Build;
using UnityEngine;
#if UNITY_EDITOR_OSX
/// <summary>
/// Unity clears Android Keystore and Key Alias passwords when it exits,
@fxm90
fxm90 / UIColor+Initializers.swift
Last active August 11, 2020 08:45
Create UIColor from RGB, RGBA, Hex or Hex-String ("#ffffff")
public extension UIColor {
/// Create color from RGB(A)
///
/// Parameters:
/// - absoluteRed: Red value (between 0 - 255)
/// - green: Green value (between 0 - 255)
/// - blue: Blue value (between 0 - 255)
/// - alpha: Blue value (between 0 - 255)
///
@hfossli
hfossli / Display.swift
Last active July 13, 2020 16:22
Display mode
import UIKit
public enum DisplayType {
case unknown
case iphone4
case iphone5
case iphone6
case iphone6plus
static let iphone7 = iphone6
static let iphone7plus = iphone6plus
@thousandlemons
thousandlemons / how-to-setup-shadowsocks-on-your-ubuntu-server.md
Last active November 20, 2021 00:14
How to setup Shadowsocks on your Ubuntu server
@ryuichis
ryuichis / Event.swift
Created October 15, 2016 13:40
Swift 3 Struct & NSCoding
public struct Event {
public internal(set) var timeStamp: Date
public internal(set) var eventTag: String
public init(timeStamp: Date, tag: String) {
self.timeStamp = timeStamp
self.eventTag = tag
}
}
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active June 22, 2024 20:31
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@Tokuriku
Tokuriku / Count lines of code in Xcode project
Last active June 20, 2024 09:30 — forked from ccabanero/Count lines of code in Xcode project
Count lines of code in SWIFT Xcode project
1. Open Terminal
2. cd to your Xcode project
3. Execute the following when inside your target project:
find . -name "*.swift" -print0 | xargs -0 wc -l
@cjddmut
cjddmut / EasingFunctions.cs
Last active May 31, 2024 12:55
Easing Functions for Unity3D
/*
* Created by C.J. Kimberlin
*
* The MIT License (MIT)
*
* Copyright (c) 2019
*
* 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