Skip to content

Instantly share code, notes, and snippets.

View mocovenwitch's full-sized avatar
🏝️
hi

Mocoven mocovenwitch

🏝️
hi
View GitHub Profile
@mocovenwitch
mocovenwitch / gist:1c85246cc6332fa2e0dc1cb7c2c35e08
Created April 3, 2017 11:18
Make plotly working with python3
# I have both python 2.7 and 3.6 running in my Mac
# working with python 2.7
sudo pip install plotpy
# working with python 3.6
sudo pip3 install plotly
@mocovenwitch
mocovenwitch / enableHTML5AppCache.java
Created April 4, 2017 05:44 — forked from jaydeepw/enableHTML5AppCache.java
Enabling HTML5 AppCache in Android Webview programatically.
private void enableHTML5AppCache() {
webView.getSettings().setDomStorageEnabled(true);
// Set cache size to 8 mb by default. should be more than enough
webView.getSettings().setAppCacheMaxSize(1024*1024*8);
// This next one is crazy. It's the DEFAULT location for your app's cache
// But it didn't work for me without this line
webView.getSettings().setAppCachePath("/data/data/"+ getPackageName() +"/cache");
@mocovenwitch
mocovenwitch / Activity
Created May 3, 2017 12:16
Manage Fragment when rotating
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
......
if (getFragmentManager().findFragmentById(R.id.fragment) == null) {
getFragmentManager().beginTransaction().replace(R.id.fragment, new MainActivityFragment()).commit();
@mocovenwitch
mocovenwitch / note.txt
Created May 30, 2017 10:43
Share link in Facebook post without integrate with Facebook sdk
https://stackoverflow.com/questions/34618514/share-text-via-intent-on-facebook-without-using-facebook-sdk
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "http://www.google.com");
startActivity(Intent.createChooser(sharingIntent, "Share via"));
@mocovenwitch
mocovenwitch / StateMachine
Created September 27, 2017 13:11 — forked from elandau/StateMachine
Rx based state machine
package com.netflix.experiments.rx;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rx.Observable;
import rx.Observable.OnSubscribe;