Skip to content

Instantly share code, notes, and snippets.

View SeongUgJung's full-sized avatar

Steve SeongUg Jung SeongUgJung

View GitHub Profile
GsonBuilder gson = new GsonBuilder();
gson.registerTypeAdapter(ResponseMessage.class, new UsingTimeDataTypeAdapter());
return gson.create().fromJson(result, ResponseMessage.class);
Connection conn = null;
Statement stmt = null;
try{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(DB_URL,USER,PASS);
stmt = conn.createStatement();
@SeongUgJung
SeongUgJung / other publishsubject
Last active August 29, 2015 14:26
publishsubject + flatmap problem
List<ChatChooseItem> chatChooseItems = getMockItems();
List<ChatChooseItem> testList = new ArrayList<>();
PublishSubject<String> publishSubject = PublishSubject.create();
publishSubject
.throttleWithTimeout(300, TimeUnit.MILLISECONDS)
.flatMap(s -> Observable.from(chatChooseItems)
.filter(chatChooseItem -> chatChooseItem.getName().toLowerCase().contains(s.toLowerCase()))
.toSortedList((lhs, rhs) -> lhs.getName().toLowerCase().compareTo(rhs.getName().toLowerCase()))
)
@SeongUgJung
SeongUgJung / read.py
Last active August 29, 2015 14:26
Python xlsx 처리 방법
from openpyxl import Workbook, load_workbook
# https://docs.djangoproject.com/en/1.8/topics/http/file-uploads/
# https://docs.djangoproject.com/en/1.8/ref/files/uploads/
# or Custom File Upload Handler
# File Upload to Temporary or Memory
def xlrd(request):
# After Uploaded....
@SeongUgJung
SeongUgJung / GoogleImageFilePath.java
Created September 25, 2015 07:29
Android Google Photos's Uri
public String getImagePath(Context context, Uri uri){
if ("content".equalsIgnoreCase(uri.getScheme())) {
if (isGoogleOldPhotosUri(uri)) {
// return http path, then download file.
return uri.getLastPathSegment();
} else if (isGoogleNewPhotosUri(uri)) {
// copy from uri. context.getContentResolver().openInputStream(uri);
return copyFile(context, uri);
} else if (isPicasaPhotoUri(uri)) {
@SeongUgJung
SeongUgJung / All_Trust_SSL.java
Created October 5, 2015 06:57
All_Trust_SSLContext
private SSLContext getSSLContext() throws KeyManagementException, NoSuchAlgorithmException {
SSLContext context = SSLContext.getInstance("SSL");
context.init(null, new TrustManager[]{new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] x509Certificates, String authType) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] x509Certificates, String authType) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
Observable.just(1,2,3)
.onBackpressureBuffer()
.observeOn(Schedulers.computation())
.subscribe(input -> {
doSomething();
});
@SeongUgJung
SeongUgJung / test.html
Created November 17, 2015 08:49
test_javascript_loop
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var i = 10;
while (--i) {
document.getElementById("demo").innerHTML += i + "<br>";
@RunWith(AndroidJUnit4.class)
public class AccountHomePresenterImplTest {
private AccountHomePresenterImpl accountHomePresenter;
private AccountHomePresenter.View viewMock;
@Before
public void setUp() throws Exception {
accountHomePresenter = AccountHomePresenterImpl_.getInstance_(JandiApplication.getContext());
viewMock = mock(AccountHomePresenter.View.class);
public class MainActivity extends Activity {
@Override public void onCreate(Bundle savedInstance) {
RecyclerView rv = findViewById(R.id.lv);
RecyclerView.Adapter adapter = new SampleAdapter();
rv.setAdapter(adapter);
adapter.add(new Data());
adapter.add(new Data()); // add Data
adapter.nofityDatasetChanged(); // refresh Screen
}