Skip to content

Instantly share code, notes, and snippets.

@LiLejia
LiLejia / ViewController.swift
Created November 19, 2019 16:12
Classic slide to unlock animation swift implemntation
//
// ViewController.swift
// GradientAnimation
//
// Created by Henry Lee on 2019/11/19.
// Copyright © 2019 Henry Lee. All rights reserved.
//
import UIKit
@LiLejia
LiLejia / GradientStruct.swift
Last active September 27, 2019 06:09
An update of @endash https://gist.github.com/endash/acda517225dc9f4bc9db for Swift 5. New `UnsafeMutableRawPointer` is a little tricky. See [here](https://www.raywenderlich.com/780-unsafe-swift-using-pointers-and-interacting-with-c). Photoshop style gradients in Core Graphics via use of CGShader (with thanks to @jernejstrasner, see his explanati…
import UIKit
func SineEaseInOutLinearAverage(x: CGFloat) -> CGFloat {
let easeInOutSine = ((cos(CGFloat.pi * x) - 1) / -2)
return (easeInOutSine + x) / 2
}
func ShadingFunctionCreate(_ startColor: UIColor, _ endColor: UIColor, _ slopeFunction: @escaping (CGFloat) -> CGFloat) -> (UnsafePointer<CGFloat>, UnsafeMutablePointer<CGFloat>) -> Void {
return { inData, outData in
let q = slopeFunction(inData[0])
@LiLejia
LiLejia / GradientStruct.swift
Last active September 27, 2019 06:06
Photoshop style gradients in Core Graphics via use of CGShader (with thanks to @jernejstrasner, see his explanation of why your gradients might not look how your designers intended http://jernejstrasner.com/2014/01/09/smooth-gradients-ios.html)
import UIKit
func SineEaseInOutLinearAverage(x: CGFloat) -> CGFloat {
let easeInOutSine = ((cos(CGFloat.pi * x) - 1) / -2)
return (easeInOutSine + x) / 2
}
func ShadingFunctionCreate(_ startColor: UIColor, _ endColor: UIColor, _ slopeFunction: @escaping (CGFloat) -> CGFloat) -> (UnsafePointer<CGFloat>, UnsafeMutablePointer<CGFloat>) -> Void {
return { inData, outData in
let q = slopeFunction(inData[0])
@LiLejia
LiLejia / GradientStruct.swift
Created September 27, 2019 06:06
Photoshop style gradients in Core Graphics via use of CGShader (with thanks to @jernejstrasner, see his explanation of why your gradients might not look how your designers intended http://jernejstrasner.com/2014/01/09/smooth-gradients-ios.html)
import UIKit
func SineEaseInOutLinearAverage(x: CGFloat) -> CGFloat {
let easeInOutSine = ((cos(CGFloat.pi * x) - 1) / -2)
return (easeInOutSine + x) / 2
}
func ShadingFunctionCreate(_ startColor: UIColor, _ endColor: UIColor, _ slopeFunction: @escaping (CGFloat) -> CGFloat) -> (UnsafePointer<CGFloat>, UnsafeMutablePointer<CGFloat>) -> Void {
return { inData, outData in
let q = slopeFunction(inData[0])
@LiLejia
LiLejia / package_name_and_sign.sh
Created March 13, 2019 07:32
Download an APK file and print the package and signature.
#!/bin/sh
# package_name_and_sign.sh https://xxx.com/xxx.apk
rm -rf tmp
mkdir tmp
cd tmp/
wget --no-check-certificate $1 -O tmp.rar
echo "Package Name:"
$ANDROID_HOME/build-tools/28.0.2/aapt dump badging tmp.rar | grep package:\ name # Find Package Name
@LiLejia
LiLejia / starSign.m
Last active December 24, 2015 23:29
从NSDate的日期获得星座,星座分个参照 http://www.chinaz.com/program/2009/1226/102350.shtml
- (NSString *)starSign:(NSDate *)date{
if(!date)
return @"处女座";
NSString *info = @"水瓶座*0120*0219#双鱼座*0220*0320#白羊座*0321*0420#金牛座*0421*0521#双子座*0522*0621#巨蟹座*0622*0722#狮子座*0723*0823#处女座*0824*0923#天秤座*0924*1023#天蝎座*1024*1122#射手座*1123*1222#摩蝎座*1222*0119#";
NSArray *array = [info componentsSeparatedByString:@"#"];
NSString *starSignString = @"摩羯座";
NSCalendar *calender = [NSCalendar currentCalendar];
@LiLejia
LiLejia / starSign.m
Last active December 24, 2015 23:29
Get star sign from NSDate
- (NSString *)starSign:(NSDate *)date{
if(!date)
return nil;
NSString *info = @"Aquarius*0120*0219#Pisces*0220*0320#Aries*0321*0420#Taurus*0421*0521#Gemini*0522*0621#Cancer*0622*0722#Leo*0723*0823#Virgo*0824*0923#Libra*0924*1023#Scorpio*1024*1122#Sagittarius*1123*1222#Capricorn*1222*0119#";
NSArray *array = [info componentsSeparatedByString:@"#"];
NSString *starSignString = @"Capricorn";
NSCalendar *calender = [NSCalendar currentCalendar];
@LiLejia
LiLejia / HD.txt
Created September 6, 2013 08:27 — forked from lexrus/HD.txt
http://devstreaming.apple.com/videos/wwdc/2013/710xfx3xn8197k4i9s2rvyb/710/710-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/202xdx2x47ezp1wein/202/202-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/200xdx2x35e1pxiinm/200/200-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/413xdx5x97itb5ek4yex3r7/413/413-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/612xax4xx65z1ervy5np1qb/612/612-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/221xex4xxohbllf4hblyngt/221/221-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/220xbx4xipaxfd1tggxuoib/220/220-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/711xcx4x8yuutk8sady6t9f/711/711-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/404xbx2xvp1eaaqonr8zokm/404/404-HD.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2013/505xbx4xrgmhwby4oiwkrpp/505/505-HD.mov?dl=1