Skip to content

Instantly share code, notes, and snippets.

View defHLT's full-sized avatar
🐔

Artem Kholodnyi defHLT

🐔
View GitHub Profile
@defHLT
defHLT / raw-resource-to-string.java
Last active August 29, 2015 14:06
read Android raw resource file to Java string
private String getRawResource(int resource) {
String res = null;
InputStream is = getContext().getResources().openRawResource(resource);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] b = new byte[1];
try {
while ( is.read(b) != -1 ) {
baos.write(b);
};
res = baos.toString();
@defHLT
defHLT / tree.pde
Last active August 29, 2015 14:06
int W = 1024;
int H = 700;
float K1 = 0.4;
float K2 = 0.6;
float LEN_DEC1 = 0.66;
float LEN_DEC2 = 0.5;
float ANGLE1 = PI/6;
float ANGLE2 = -PI/6;
int STEPS = 14;
<html>
<head>
<title>My first Three.js app</title>
<style> body { margin: 0; } canvas { width: 100%; height: 100% } </style>
<script src="js/three.min.js"></script>
<script src="js/TrackballControls.js"></script>
</head>
<body>
<script>
(ns com.mlatu.clojure.test.main
(:use [neko.activity :only [defactivity set-content-view! *a]]
[neko.threading :only [on-ui]]
[neko.notify]
[neko.resource]))
(fire (*a) :notification
(notification :icon (get-resource (*a) :drawable :ic-launcher)
:ticker-text "You've got mail"
#!/usr/bin/clojure
; Created: Fri Jan 9 16:10:56 EET 2015
; encoding: utf-8
(defn burrows-wheeler [s]
(let [size (count s)]
(->>
(repeat size s)
(apply str)
#!/usr/bin/clojure
; Created: Fri Jan 9 16:10:56 EET 2015
; encoding: utf-8
(defn burrows-wheeler [s]
(let [size (count s)]
(->>
(repeat 2 s)
(apply str)
#!/bin/bash
# Send power button press if screen is off
(adb shell dumpsys power | grep -q "Display Power: state=OFF" ) && adb shell input keyevent KEYCODE_POWER
# Send menu key press to unlock
adb shell input keyevent 82
# Even if failed let the gradle build continue
true
-> ice ~ % adb shell input
Usage: input [<source>] <command> [<arg>...]
The sources are:
mouse
keyboard
joystick
touchnavigation
touchpad
trackball
private void init() {
paint = new Paint();
paint.setColor(Color.BLUE);
paint.setAntiAlias(true);
paint.setStrokeWidth(50);
paint.setStyle(Paint.Style.STROKE);
paintFill = new Paint();
paintFill.setColor(Color.RED);
paint.setAntiAlias(true);
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
float scale = getMeasuredWidth() / mMaxImageWidth;
int width = Math.round(getMeasuredWidth() * scale);
int height = Math.round(getMeasuredHeight() * scale);
setMeasuredDimension(width, height);
}