Skip to content

Instantly share code, notes, and snippets.

View misdake's full-sized avatar

misdake misdake

  • Shanghai
  • 16:33 (UTC +08:00)
  • X @rSkip
View GitHub Profile
@misdake
misdake / GLTextureView.java
Created October 22, 2015 03:42 — forked from eleventigers/GLTextureView.java
GLTextureView from GLSurfaceView
import java.io.Writer;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGL11;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL;
@misdake
misdake / MapPanel3D.java
Created July 11, 2013 10:21
JOGL create view.
setLayout(new BorderLayout(0, 0));
final GLCanvas canvas = new GLCanvas();
canvas.setMinimumSize(new Dimension()); //fix a GLCanvas resize bug.
animator = new Animator(canvas); //TODO switch to FPSAnimator to save energy.
canvas.addGLEventListener(OpenglCore.getInstance());
this.add(canvas);
@misdake
misdake / OpenglUtil.java
Created July 24, 2013 02:50
Android get resourceId from fileName
public static int getResourceId(Context context, String name) {
name = name.toLowerCase();
return context.getResources().getIdentifier(name, "drawable", context.getPackageName());
}
@misdake
misdake / OpenglActivity.java
Created July 24, 2013 05:37
Activity "keep screen on" & "full screen, landscape"
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//Full screen, landscape.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
@misdake
misdake / volume
Last active December 25, 2015 10:22
find proper volume numbers
boolean[] r = new boolean[500];
Arrays.fill(r, false);
r[2] = r[3] = r[5] = true;
for (int i = 2; i != 100; i++) {
if(r[i]) {
r[i*2] = r[i*3] = r[i*5] = true;
System.out.println(i);
}
}
@misdake
misdake / java_object_sizes.txt
Last active February 24, 2016 09:40
java object sizes on Oracle JRE.
64bit JVM 32bit JVM
16 8 new Object()
216 216 new char[100]
16 16 new Integer(1)
24 16 new Long(1)
24 16 new Double(1)
40 40 new ArrayList()
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF8">
<meta name="description" content="URL selfhosting content">
<meta name="keywords" content="self hosting web pages by abusing the url">
<meta name="author" content="MJS 2016-02-25">
<script>
LZString=function(){function o(o,r){if(!t[o]){t[o]={};for(var n=0;n<o.length;n++)t[o][o.charAt(n)]=n}return t[o][r]}var r=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",t={},i={compressToBase64:function(o){if(null==o)return"";var r=i._compress(o,6,function(o){return n.charAt(o)});switch(r.length%4){default:case 0:return r;case 1:return r+"===";case 2:return r+"==";case 3:return r+"="}},decompressFromBase64:function(r){return null==r?"":""==r?null:i._decompress(r.length,32,function(e){return o(n,r.charAt(e))})},compressToUTF16:function(o){return null==o?"":i._compress(o,15,function(o){return r(o+32)})+" "},decompress
@misdake
misdake / enum.java
Last active May 5, 2016 10:42
触目惊心的enum get
public final static T get(int value) {
for (int i = 0; i < values().length; i++) {
if (values()[i].value == value) {
return values()[i];
}
}
return null;
}
@misdake
misdake / JpegExif.java
Created August 4, 2016 12:08
read jpeg exif
//https://github.com/drewnoakes/metadata-extractor
public class JpegExif {
public static void main(String[] args) throws ImageProcessingException, IOException {
File file = new File("E:/org_3e1fa47a903c1ccb_1470295646000.jpg");
int w = 4;
int h = 3;
double rw = 1.0 * w / Math.hypot(w, h);
double rh = 1.0 * h / Math.hypot(w, h);
1 CppCon 2015: Bjarne Stroustrup “Writing Good C++14”
2 CppCon 2015: Herb Sutter "Writing Good C++14... By Default"
3 CppCon 2015: Sean Parent "Better Code: Data Structures"
4 CppCon 2015: Chandler Carruth "Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My!"
5 CppCon 2015: Eric Niebler "Ranges for the Standard Library"
6 CppCon 2015: Vittorio Romeo “Implementation of a component-based entity system in modern C++”
7 CppCon 2015: Joel Falcou PART 1 “Expression Templates - Past, Present, Future”
8 CppCon 2015: Scott Wardle “Memory and C++ debugging at Electronic Arts”
9 CppCon 2015: André Bergner “Faster Complex Numbers”
10 CppCon 2015: Louis Dionne “C++ Metaprogramming: A Paradigm Shift"