Skip to content

Instantly share code, notes, and snippets.

View brownsoo's full-sized avatar
🐢
Step by step

brownsoo brownsoo

🐢
Step by step
View GitHub Profile
@brownsoo
brownsoo / checking-ios-version.txt
Last active February 7, 2018 05:33
Checking iOS version in above 8.0
NSOperatingSystemVersion ios8_0_1 = (NSOperatingSystemVersion){8, 0, 1};
if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:ios8_0_1]) {
// iOS 8.0.1 and above logic
} else {
// iOS 8.0.0 and below logic
}
sudo gem install -n /usr/local/bin cocoapods

변경이력

  • 2013/10/15: Dianne Hackborn의 언급에 대한 번역은 안세원님이 교정해주신 내용으로 교체합나디.

AsyncTask는 API Level 13이상 버전이 설치된 기기에서 android:targetSdkVersion가 13이상 일 때 여러 개의 AsyncTask가 동시에 실행되어도 순차적으로 호출됩니다.

기기의 버전뿐만 아니라 targetSDK 설정에도 영향을 받으므로 target SDK 설정을 변경할 때 유의해야 합니다. 그리고 가능하다면 목적별로 스레드풀을 분리하고, 스레드의 갯수가 늘어나는 것에 대비해 무작정 큰 최대값을 주는것보다는 Timeout과 RejectionPolicy로 관리를 하는 편이 바람직합니다.

@brownsoo
brownsoo / regular_expression_number_and_char_only.java
Last active February 3, 2017 02:25
Regular expression to check if the string contains only number and char.
// 문자열이 문자와 숫자로만 되어 있는지 확인
public static boolean checkNumberCharMixed(@NonNull String password) {
Pattern p = Pattern.compile("^([0-9]+[a-zA-Z]+|[a-zA-Z]+[0-9]+)[0-9a-zA-Z]*$");
return p.matcher(password).matches();
}
@brownsoo
brownsoo / regular_expression_same_char_repeation.java
Created February 3, 2017 02:27
Regular expression to check if the same char is repeated.
// 문자열에 반복되는 문자가 있는지 확인
public static boolean checkSameCharRepeated(@NonNull String password, int repeatLength) {
if (repeatLength <= 1) return false;
Pattern p = Pattern.compile(".*([a-zA-Z0-9])\\1{"+ (repeatLength - 1) +",}.*");
return p.matcher(password).matches();
}
@brownsoo
brownsoo / regular_expression_consecutive_chars.java
Created February 3, 2017 02:29
Regular expression to check if the consecutive chars exist.
// 문자열에 연속되는 문자가 있는지 확인
public static boolean checkConsecutiveChars(@NonNull String password, int consecutiveLength) {
if (password.length() < consecutiveLength) {
return false;
}
for (int i = 0; i <= password.length() - consecutiveLength; i++) {
char s1 = password.charAt(i);
char s2 = password.charAt(i + 1);
@brownsoo
brownsoo / regular_expression_whitelist.js
Last active February 9, 2017 10:21
Regular expression for white character list
// 정해진 문자, 숫자, 특수문자가 아닌 문자가 있는지 체크 -- [^X]형식으로
// 입력가능한 특수문자: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
var reg = /[^a-zA-Z0-9!"#$%&'\(\)\*+,\-./:;<=>?@\[\\\]\^_`\{|\}~]/g;
@brownsoo
brownsoo / ping-host.java
Last active February 13, 2017 10:07
Check Reachability using ping in Java
// 주의사항 http://stackoverflow.com/a/10145643
// The isReachable failure is an outstanding issue.
// Again - there are several online resources indicating that there is no "perfect" way of doing this at the time of this writing,
// due to the way the JVM tries to reach hosts - I guess it is an intrinsically platform specific task which, although simple, hasn't yet been abstracted sufficiently by the JVM.
private boolean ping(String host) {
Runtime runTime = Runtime.getRuntime();
String host = host;
@brownsoo
brownsoo / resizable-left-child-view.xml
Created June 19, 2017 05:38
chat style layout - resizable left child view with following right child view
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- left wrap_content view is resizable but not exceeds following child view -->
<TextView
android:id="@+id/parcel_number"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:fontFamily="@string/vt__font_family_light"
android:textColor="@color/vt__shipment__process__order__parcel__number"
@brownsoo
brownsoo / email-regex.js
Last active June 29, 2017 02:42
Email - Regular expression (javascript)
// 이메일 정규 표현식
var pattern = /^(([^<>()[\]\\.,;:\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,}))$/