Skip to content

Instantly share code, notes, and snippets.

View jongha's full-sized avatar

Jong-Ha Ahn jongha

View GitHub Profile
@jongha
jongha / uva-440.cpp
Created August 27, 2019 06:34
UVa 440 - Eeny Meeny Moo
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <list>
#include <algorithm>
#include <string.h>
#include <string>
#include <queue>
#include <math.h>
@jongha
jongha / uva-10034.cpp
Created July 29, 2019 01:06
UVa 10034 - Freckles
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#define MAX 1000
@jongha
jongha / uva-11311.cpp
Created July 29, 2019 00:50
UVa 11311 - Exclusively Edible
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <list>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
using namespace std;
@jongha
jongha / appbar_always_elevated.xml
Created June 14, 2019 10:25
Appbar elevation in expanded state on Android
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="320dp"
android:stateListAnimator="@drawable/appbar_always_elevated"
android:fitsSystemWindows="true">
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
@jongha
jongha / s3-bucket-policy
Created June 14, 2019 04:37
How to Allow Public Access to an Amazon S3 Bucket Automatically
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Action": "s3:GetObject",
"Effect": "Allow",
"Resource": "arn:aws:s3:::[NAME]/*",
"Principal": "*"
}
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string.h>
#define MAX 1000
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <list>
#include <algorithm>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
@jongha
jongha / NonSwipeableViewPager.kt
Created May 23, 2019 08:11
Non Swipeable ViewPager in Android
class NonSwipeableViewPager : ViewPager {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
return false
}
override fun onTouchEvent(event: MotionEvent): Boolean {
return false
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <list>
#include <algorithm>
#include <string.h>
#include <string>
#include <queue>
#include <math.h>
@jongha
jongha / node-http-basic-auth.js
Created May 15, 2019 09:50
HTTP basic auth for Node.js
app.use((req, res, next) => {
const auth = { login: 'username', password: 'password' };
const b64auth = (req.headers.authorization || '').split(' ')[1] || '';
const [login, password] = new Buffer(b64auth, 'base64').toString().split(':');
if (login && password && login === auth.login && password === auth.password) {
return next();
}
res.set('WWW-Authenticate', 'Basic realm="401"');