Skip to content

Instantly share code, notes, and snippets.

View voituk's full-sized avatar

Vadym Voitiuk voituk

  • Amazon Web Services
  • Berlin, Germany
  • LinkedIn in/voituk
View GitHub Profile
@voituk
voituk / hnac-poc.js
Created October 15, 2019 07:46
Simple HMAC URL signature & Verification in JavaScript (node)
#!/usr/bin/env node
const URL = require('url').URL,
crypto = require('crypto');
/**
*
* @param string url
@voituk
voituk / android.getLogcat.java
Created July 19, 2013 13:59
android.getLogcat.java
public static String getLogcat() {
BufferedReader br = null;
try {
Process process = Runtime.getRuntime().exec( new String[] {
"logcat", "-d" //, "-v", "time", "-s", "*:W"
});
br = new BufferedReader( new InputStreamReader(process.getInputStream()), 8*1024);
String line;
StringBuilder log = new StringBuilder();
while ( (line = br.readLine()) != null) {
@voituk
voituk / js-test-2.js
Created July 18, 2013 15:11
js-test-2
// what's the difference (if any) between
setInterval(function() {
console.log("hello")
}, 1000);
// and:
setTimeout(function() {
console.log("hello")
@voituk
voituk / gist:2359091
Created April 11, 2012 12:39
Android: Load + resize image
try {
BitmapFactory.Options options = new BitmapFactory.Options() {{
inJustDecodeBounds = true;
}};
BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri), null, options);
final int wResample = (options.outWidth > profileThumb.getWidth()) ? options.outWidth / profileThumb.getWidth() : 1;
final int hResample = (options.outHeight > profileThumb.getHeight()) ? options.outHeight / profileThumb.getHeight() : 1;
@voituk
voituk / gist:1965613
Created March 3, 2012 11:25
PHP 5.4 WTF?
<?php
function vvv() {
return [10 => 1111, 20 => 222222, 30, 40];
}
// Works OK
var_dump( vvv()[10] );
function ccc() {
return function() {
@voituk
voituk / js-test-1
Created May 22, 2011 10:41
JavaScript Test 1
/**
* What you get in console after this script execution?
*/
for (var i=0; i<5; i++ ) {
setTimeout(function() {
console.log(i)
}, i*1000)
}