Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

411 abilogos

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