This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 이메일 정규표현식 | |
public static boolean testEmailFormat(String text) { | |
if (TextUtils.isEmpty(text)) return false; | |
Pattern pattern = Pattern.compile("^(([^<>()\\[\\]\\\\.,;:\\s@\"]" + | |
"+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(.+))" + | |
"@" + | |
"((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])" + | |
"|(([a-zA-Z-0-9]+\\.)+[a-zA-Z]{2,}))$"); | |
return pattern.matcher(text).matches(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- drawable-v21 --> | |
<?xml version="1.0" encoding="utf-8"?> | |
<ripple xmlns:android="http://schemas.android.com/apk/res/android" | |
android:color="?android:attr/colorControlHighlight"> | |
<item | |
android:id="@android:id/mask"> | |
<shape android:shape="rectangle"> | |
<solid android:color="#000000"/> | |
<corners android:radius="5dp"/> | |
</shape> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Android architecture components: Lifecycle | |
# LifecycleObserver's empty constructor is considered to be unused by proguard | |
-keepclassmembers class * implements android.arch.lifecycle.LifecycleObserver { | |
<init>(...); | |
} | |
# ViewModel's empty constructor is considered to be unused by proguard | |
-keepclassmembers class * extends android.arch.lifecycle.ViewModel { | |
<init>(...); | |
} | |
# keep Lifecycle State and Event enums values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void updateVisibleTaskIndex() { | |
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); | |
if (layoutManager instanceof LinearLayoutManager) { | |
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager; | |
int first = linearLayoutManager.findFirstVisibleItemPosition(); | |
int last = linearLayoutManager.findLastVisibleItemPosition(); | |
RecyclerView.ViewHolder viewHolder; | |
for (int i = first; i <= last; i++) { | |
viewHolder = recyclerView.findViewHolderForAdapterPosition(i); | |
if (viewHolder instanceof TaskViewHolder) { //TaskViewHolder is custom holder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Promise like subscriber, works with Equatable types and Optionals of Equatable types | |
// ie: | |
// let observer = document.mainStore | |
// .select { (state) -> UIState in state.ui } | |
// .then { _ in called += 1 } | |
// or | |
// let observer = document.mainStore | |
// .select { (state) -> String? in state.ui.selection } | |
// .then { _ in called += 1 } | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// find email, password (Token) | |
grep -A2 'trunk.cocoapods.org' ~/.netrc | |
// replace email and name | |
curl -v -H "Authorization: Token <MY CURRENT TOKEN>" -H "Content-Type: application/json" -X POST -d '{"email":"<MY EMAIL>","name":"<MY NEW NAME>","description":"<My DESCRIPTION>"}' https://trunk.cocoapods.org/api/v1/sessions | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in UIViewController | |
func setupHideKeypadWhenTappedAround() { | |
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap)) | |
tap.cancelsTouchesInView = false | |
view.addGestureRecognizer(tap) | |
// responsive keyboard frame | |
NotificationCenter.default.addObserver(self, selector: #selector(handleKeyboardWillChange), | |
name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension UIImage { | |
func tint(_ color: UIColor) -> UIImage { | |
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) | |
let renderer = UIGraphicsImageRenderer(size: rect.size) | |
let result = renderer.image { c in | |
color.setFill() | |
c.fill(rect) | |
self.draw(in: rect, blendMode: .destinationIn, alpha: 1) | |
} | |
return result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension UIImage { | |
func round(_ radius: CGFloat) -> UIImage { | |
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) | |
let renderer = UIGraphicsImageRenderer(size: rect.size) | |
let result = renderer.image { c in | |
let rounded = UIBezierPath(roundedRect: rect, cornerRadius: radius) | |
rounded.addClip() | |
if let cgImage = self.cgImage { | |
UIImage(cgImage: cgImage, scale: self.scale, orientation: self.imageOrientation).draw(in: rect) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension DateFormatter { | |
static let iso8601Full: DateFormatter = { | |
let formatter = DateFormatter() | |
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" | |
formatter.calendar = Calendar(identifier: .iso8601) | |
formatter.timeZone = TimeZone(secondsFromGMT: 0) | |
formatter.locale = Locale(identifier: "en_US_POSIX") | |
return formatter |