Skip to content

Instantly share code, notes, and snippets.

View SpiritOfDarkDragon's full-sized avatar

SpiritOfDarkDragon

View GitHub Profile
@SpiritOfDarkDragon
SpiritOfDarkDragon / Change width drawer menu in android
Created October 15, 2014 14:38
Way to set non-default width of drawer menu (side-/slide-menu) in Android.
<android.support.v4.widget.DrawerLayout
...
>
<FrameLayout
...
</FrameLayout>
<fragment android:id="@+id/navigation_drawer"
...
android:layout_width="@dimen/navigation_drawer_width"
.../>
Update .gitmodules
[submodule "example"]
path = example
url = https://github.com/webhat/example.git
Update .git/config too
[submodule "example"]
url = https://github.com/webhat/example.git
//Convert from String to byte[]:
String s = "some text here";
byte[] b = s.getBytes("US-ASCII");
//Convert from byte[] to String:
byte[] b = {(byte) 99, (byte)97, (byte)116};
String s = new String(b, "UTF-8");
Set the CheckBox as focusable="false" in your XML layout. Otherwise it will steal click events from the list view.
public static Bitmap resizeImage(Bitmap inputBitmap, int newHeight, int newWidth) {
int width = inputBitmap.getWidth();
int height = inputBitmap.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
return Bitmap.createBitmap(inputBitmap, 0, 0, width, height, matrix, false);
}
document.body.addEventListener('touchstart', function(e) {
//
});
document.body.addEventListener('touchmove', function(e) {
//
});
document.body.addEventListener('touchend', function(e) {
//
@SpiritOfDarkDragon
SpiritOfDarkDragon / touch-события в js
Last active August 29, 2015 14:04
Трогательные события в JavaScript :)
from: http://www.javascriptkit.com/javatutors/touchevents.shtml
touchstart
Triggers when the user makes contact with the touch surface and creates a touch point inside the element the event is bound to.
touchmove
Triggers when the user moves the touch point across the touch surface.
touchend
Triggers when the user removes a touch point from the surface. It fires regardless of whether the touch point is removed while inside the bound-to element, or outside, such as if the user's finger slides out of the element first or even off the edge of the screen.
@SpiritOfDarkDragon
SpiritOfDarkDragon / detect scroll to top
Created July 24, 2014 12:22
Как определить, прокрутили ли мы scroll до самого верха.
/////JS/////
$(window).scroll(function(){
if ($(this).scrollTop() == 0) {
$('span').html("верх");
}
else {
$('span').html("не верх");
}
});
////CSS////
@SpiritOfDarkDragon
SpiritOfDarkDragon / Canvas
Last active November 7, 2023 05:01
Маленькая шпоргалка по canvas
//инициализация
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
//размеры канваса
w = canvas.width;
h = canvas.height;
//масштаб, например в 2 раза больше
ctx.scale(2,2)