Skip to content

Instantly share code, notes, and snippets.

@comoc
comoc / AndroidApplicationListing.java
Last active January 4, 2020 16:27
How to list installed applications on Android.
//{ Locate follows into your class
public static class ApplicationInfo {
public String label;
public String name;
public String packageName;
public Drawable icon;
@Override
public String toString() {
return "label:" + label + " name:" + name + " packageName:"
@comoc
comoc / FullscreenExample.pde
Created August 14, 2013 05:52
An example of fullscreen sketch under multi-screen environment for Processing.
// Fullscreen sketch example under multi-screen environment
// @see http://processing.org/discourse/beta/num_1185318989.html
import java.awt.*;
static final int PREFERRED_GRAPHICS_DEVICE_INDEX = 1; //< This value represents the target monitor.
Rectangle monitorBounds = new Rectangle();
public void init() {
@comoc
comoc / AndroidLaunchExternalActivity.java
Last active August 31, 2024 08:02
Launch an external activity with its package and class name. For example, the package name is "com.example.hello", and the class name is "com.example.hello.MainActivity".
/**
* Launch an activity.
* @param context The context to use. Usually your Application or Activity object.
* @param packageName The name of the package that the component exists in. Can not be null.
* @param className The name of the class inside of pkg that implements the component. Can not be null.
* @see {ANDROID_SDK}/samples/android-{VERSION}/Home/src/com/example/android/home/Home.java
*/
private void launch(Context context, String packageName, String className) {
if (context == null || packageName == null || className == null)
return;
html, body {
margin:0;
padding:0;
height:100%;
}
html {
background:-webkit-linear-gradient(left, #000, #fff);
background: -moz-linear-gradient(left, #000, #fff);
background: -o-linear-gradient(left, #000, #fff);
@comoc
comoc / mtu_max_mac.sh
Created October 2, 2013 02:00
Inspect the maximum MTU value of your Mac. Please specify the IP value to your environment.
#!/usr/bin/env ruby
ruby -e 'IP="192.168.1.1"; puts "Progress..."; for i in 1454..1500 do; cmd="ping -D -c 1 -s " + i.to_s + " " + IP; s=`#{cmd} 2>&1`; if s.include?("100.0% packet loss") && !s.include?("too") then; puts IP + " was not found"; exit(1); elsif s.include?("too") then ; puts "Max MTU is " + (i - 1).to_s; exit(0) end; end'
@comoc
comoc / ClearCanvas.java
Created October 9, 2013 02:30
Clear the Canvas of a SurfaceView for Android.
// Obtain a SurfaceView.
// SurfaceView surfaceView = (SurfaceView)findViewById(R.id.surfaceView1);
Canvas canvas = surfaceView.getHolder().lockCanvas();
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
// Draw someting
surfaceView.getHolder().unlockCanvasAndPost(canvas);
@comoc
comoc / gist:7265141
Last active December 27, 2015 04:09
In OpenGL ES, the API specification of glDrawElements, type must be GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT.
As you can see in http://www.khronos.org/opengles/sdk/docs/man/xhtml/glDrawElements.xml
void glDrawElements( GLenum mode,
GLsizei count,
GLenum type,
const GLvoid * indices);
type
Specifies the type of the values in indices. Must be GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT.
@comoc
comoc / gist:7539796
Last active October 3, 2017 15:23
[Unity] open a file dialog at runtime.

Here is very useful demo.

Take a look at this post.

Then downlowd and import Browser Demo Project.unitypackage.

You can receive a selection by implementing SendMessage, BroadcastMessage or something like that in Browser.cs.

@comoc
comoc / file0.js
Last active August 29, 2015 14:28
Google Maps APIで外部のKMLファイルを表示するときの注意点 ref: http://qiita.com/comocc/items/3fc93859cb3d1955398f
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 11,
center: {lat: 35.681269, lng: 41.876}
});
var ctaLayer = new google.maps.KmlLayer({
url: 'http://localhost/tokyost.kml', // NG
map: map
});
@comoc
comoc / file0.txt
Last active May 26, 2016 10:53
node+socket.io+expressでサーバーとWebページ間で通信するためのスニペット ref: http://qiita.com/comocc/items/70358fc8e17df7a15098
.
|-- index.html
|-- index.js
|-- node_modules
|-- package.json