Skip to content

Instantly share code, notes, and snippets.

View owen800q's full-sized avatar

owen800q

  • Singapore
View GitHub Profile
@owen800q
owen800q / ApacheHttpClientMultiPartUpload.java
Created September 8, 2018 07:28 — forked from damianmcdonald/ApacheHttpClientMultiPartUpload.java
Multi Part Upload using Apache HttpClient 4
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.HttpClientBuilder;
import org.json.JSONObject;
@owen800q
owen800q / CharlesProxy_Configuration.opt
Created September 28, 2018 07:24
How to configure CharlesProxy 4.2.7 on Ubuntu 16.04
Proxy settings have not been autoconfigured by default. You need to configure Proxy settings manually
On windows, it's automatically configured. This issue troubled me for few days. Here's how I solved it
There are two approaches to configure proxy setting on ubuntu
By terminal
step 1: run nano .bashrc
@owen800q
owen800q / CharlesProxy_Configuration.opt
Created September 28, 2018 07:24
How to configure CharlesProxy 4.2.7 on Ubuntu 16.04
Proxy settings have not been autoconfigured by default. You need to configure Proxy settings manually
On windows, it's automatically configured. This issue troubled me for few days. Here's how I solved it
There are two approaches to configure proxy setting on ubuntu
By terminal
step 1: run nano .bashrc
@owen800q
owen800q / 001.png
Last active September 28, 2018 07:31
How to configure CharlesProxy 4.2.7 on Ubuntu 16.04
001.png
@owen800q
owen800q / gist:e0fa3c845f3f866cb6b8ad726b1150da
Created December 10, 2018 05:33
How to connect mysql-server 8 running on a docker container from the host using workbench
When I tried to connect mysql server with root user that's running on a docker container
The warm message was shown Host '172.18.0.1' is not allowed to connect to this MySQL server
In MySQL database, execute this SQL script to list all existing database users
SELECT host, user FROM mysql.user;
It will display a table, for example like this:
+------------+------------------+
@owen800q
owen800q / gist:ebecb6602d724b4038233830e19e8555
Created December 11, 2018 12:57
Copy files from a docker container to host
docker cp <containerId>:/file/path/within/container /host/path/target
@owen800q
owen800q / gist:7ef0fd259ae582913a8e8c9cabfed743
Last active December 16, 2018 09:06
Common commands for Python
Note different python builds can have different modules, they do not share modules
Python 2.7 has it own pip and pipenv
Python 3.7 has it pip3 and pipenv
Upgrading pip3 and pipenv for python 3
pip3 install --upgrade pip.
@owen800q
owen800q / jpa-cheatsheet.java
Created February 13, 2019 12:04 — forked from jahe/jpa-cheatsheet.java
JPA Cheatsheet
/*
JPA (Java Persistence API)
Transaction Management with an Entity-Mananger:
---
entityManager.getTransaction().begin();
entityManager.persist(<some-entity>);
entityManager.getTransaction().commit();
entityManager.clear();
@owen800q
owen800q / persistence.xml
Created February 13, 2019 12:05 — forked from mortezaadi/persistence.xml
persistence xml configurations for major databases and jpa providers
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<!-- derby -->
@owen800q
owen800q / spring-boot-cheatsheet.java
Created February 13, 2019 12:10 — forked from jahe/spring-boot-cheatsheet.java
Spring Boot Cheatsheet
// Enable component-scanning and auto-configuration with @SpringBootApplication Annotation
// It combines @Configuration + @ComponentScan + @EnableAutoConfiguration
@SpringBootApplication
public class FooApplication {
public static void main(String[] args) {
// Bootstrap the application
SpringApplication.run(FooApplication.class, args);
}
}