This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//for zoom detection | |
px_ratio = window.devicePixelRatio || window.screen.availWidth / document.documentElement.clientWidth; | |
$(window).resize(function(){isZooming();}); | |
function isZooming(){ | |
var newPx_ratio = window.devicePixelRatio || window.screen.availWidth / document.documentElement.clientWidth; | |
if(newPx_ratio != px_ratio){ | |
px_ratio = newPx_ratio; | |
console.log("zooming"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//method to convert your text to image | |
public static Bitmap textAsBitmap(String text, float textSize, int textColor) { | |
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); | |
paint.setTextSize(textSize); | |
paint.setColor(textColor); | |
paint.setTextAlign(Paint.Align.LEFT); | |
float baseline = -paint.ascent(); // ascent() is negative | |
int width = (int) (paint.measureText(text) + 0.0f); // round | |
int height = (int) (baseline + paint.descent() + 0.0f); | |
Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Validate Estonian national identification code. | |
* | |
* Copyright (c) 2020 Ali Hakami | |
* port from @author Mika Tuupola (javascript) | |
* https://gist.github.com/tuupola/180321 | |
* | |
* Licensed under the MIT license: | |
* http://www.opensource.org/licenses/mit-license.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//its a js hack for having multiline string like python`s ''' multi line ''' | |
//source: https://tomasz.janczuk.org/2013/05/multi-line-strings-in-javascript-and.html | |
var html = (function () {/* | |
multiline with | |
white spaces | |
and newlines | |
*/}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]; |