Skip to content

Instantly share code, notes, and snippets.

View abilogos's full-sized avatar
🏠
Working from home

ǃшɒʞɒH ǃǀɄ abilogos

🏠
Working from home
View GitHub Profile
@abilogos
abilogos / detect-zoom.js
Created November 24, 2019 20:24
Getting browser Zoom level
//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");
@abilogos
abilogos / setImageAsBackground.java
Created March 14, 2020 09:29
Android Java Development in case of Using an Layout Element that hasnot text attribute, a string can convert to an bitmap
//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);
@abilogos
abilogos / isikukood.php
Last active April 13, 2020 09:54
Validate Estonian National code
<?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
@abilogos
abilogos / multiline_string_template.js
Last active February 13, 2021 15:27
A Template to have Multiline String without appending strings
//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];