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,}))$/