Skip to content

Instantly share code, notes, and snippets.

View praveen-vishnu's full-sized avatar
🏠
Working from home

Praveen Vishnu praveen-vishnu

🏠
Working from home
View GitHub Profile
@praveen-vishnu
praveen-vishnu / Currying technique
Created February 12, 2023 10:47
JavaScript where there will be an infinite call to greet(). The expected outcome is to have the greetings concatenated with each call. console.log(greet('hello').greet('world').greet())
let greet = function (a) {
return {
greet: function (b) {
return b ? greet(a + " " + b) : a;
}
}
};
console.log(greet('hello').greet('world').greet())
@praveen-vishnu
praveen-vishnu / index.js
Created January 25, 2023 08:46
Magicaldrome String
/**
*
A Magicaldrome String is a string of characters that reads
the same forward and backward when characters are read in groups of
two and the groups of two are always read from left to right.
For example, "abcdcdab" is a
Magicaldrome String because the first two characters are the same as the
last two characters in the string, namely "ab"; and the 3rd and 4th
characters from the left are the same as the 4th and 3rd characters from
@praveen-vishnu
praveen-vishnu / index.html
Last active February 11, 2020 08:08
Upload crop & save
<main class="page">
<h2>Upload ,Crop and save.</h2>
<!-- input file -->
<div class="box">
<input type="file" id="file-input">
</div>
<!-- leftbox -->
<div class="box-2">
<div class="result"></div>
</div>
@praveen-vishnu
praveen-vishnu / index.html
Last active February 11, 2020 07:47
HTML5 File Bindings with upload preview and drag and drop
<div class="container">
<div class="well" data-bind="fileDrag: fileData">
<div class="form-group row">
<div class="col-md-6">
<img style="height: 125px;" class="img-rounded thumb" data-bind="attr: { src: fileData().dataURL }, visible: fileData().dataURL">
<div data-bind="ifnot: fileData().dataURL">
<label class="drag-label">Drag file here</label>
</div>
</div>
<div class="col-md-6">
@praveen-vishnu
praveen-vishnu / image_url_to_base64.js
Created February 3, 2020 16:42
Convert an image url to a base64 data URL
this.toDataURL(this.data.photoUrl, (dataUrl) => {
console.log(dataUrl);
})
toDataURL(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var reader = new FileReader();
@praveen-vishnu
praveen-vishnu / angular-image-to-base64.ts
Last active February 3, 2020 11:12
Convert image file to base64
handleFileSelect(evt){
var files = evt.target.files;
var file = files[0];
if (files && file) {
var reader = new FileReader();
reader.onload =this._handleReaderLoaded.bind(this);
reader.readAsBinaryString(file);