Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Joshy Francis JoshyFrancis

🏠
Working from home
View GitHub Profile
@JoshyFrancis
JoshyFrancis / jspdf_malayalam_unicode_printing.js
Created Sep 26, 2020
Print Malayalam in PDF Documents with jsPDF, converts malayalam unicode to ascii and uses ascii Thiruvachanam font.
View jspdf_malayalam_unicode_printing.js
/*
കര്‍ത്താവായ യേശുവില്‍ വിശ്വസിക്കുക; നീയും നിന്റെ കുടുംബവും രക്ഷപ്രാപിക്കും.
jspdf_malayalam_unicode_printing.js
Print Malayalam in PDF Documents with jsPDF, converts malayalam unicode to ascii and uses ascii Thiruvachanam font.
get https://github.com/MrRio/jsPDF
<script src="jsPDF-1.5.3/dist/jspdf.min.js" type="text/javascript"></script>
Goto Sampele code section
View document width and height easy solution
How to find out the document width and height very easily?
in HTML
<span id="hidden_placer" style="position:absolute;right:0;bottom:0;visibility:hidden;"></span>
in javascript
var c=document.querySelector('#hidden_placer');
var r=c.getBoundingClientRect();
@JoshyFrancis
JoshyFrancis / js_stringify.js
Last active May 22, 2018
Stringify a javascript object to string(not JSON) and vice versa
View js_stringify.js
function js_stringify(obj){
switch(typeof(obj)){
case 'string':
return '"'+ obj + '"' ;
break;
case 'undefined':case 'number':case 'boolean': case 'null':
//undefined=String(undefined);
return String(obj) ;
break;
case 'function':
@JoshyFrancis
JoshyFrancis / parse_javascript_array.php
Last active May 22, 2018
Parse Javascript array which is not in JSON fromat, into PHP array.
View parse_javascript_array.php
function parse_javascript_array($s_arr,$date_format='Y-m-d H:i:s'){
$sample_s_arr='
[{
Customer_Name: "Opening Balance",
DebitAmount: "0.00",
CreditAmount: 0.00,
BalanceAmount: "0.00"
}, {
ID: 890,
@JoshyFrancis
JoshyFrancis / replace_within_tags.js
Last active May 22, 2018
JavaScript function to replace/highlight any content within html
View replace_within_tags.js
var replace_within_tags=function(str,find,replace){//replace_within_tags('<a href="javascript:;"> an example <span> another <b>exa</b>mple</span> </a>','exa','EXA');
str=str+'';
find=(find+'').toLowerCase();
replace=replace+'';
var c='',tag_open=false,out='',temp='';
for(var i=0;i<str.length;i++){
c=str.substr(i,1);
switch(c){
case '<':
out+=temp;