Skip to content

Instantly share code, notes, and snippets.

View git-ashish's full-sized avatar
🏠
Freelancing – Open to exciting opportunities

Ashish Singh git-ashish

🏠
Freelancing – Open to exciting opportunities
View GitHub Profile
@git-ashish
git-ashish / full_text_search.js
Created March 23, 2017 14:20
Full text search in Javascript using regex
function replaceAccentedChar(str) {
return str.replace(/[\u00c0-\u00c5]/gm, 'A')
.replace(/[\u00c6]/gm, 'AE')
.replace(/[\u00c7]/gm, 'C')
.replace(/[\u00c8-\u00cb]/gm, 'E')
.replace(/[\u00cc-\u00cf]/gm, 'I')
.replace(/[\u00d0]/gm, 'D')
.replace(/[\u00d1]/gm, 'N')
.replace(/[\u00d2-\u00d6]/gm, 'O')
.replace(/[\u00d8]/gm, 'O')
@git-ashish
git-ashish / 0.md
Created April 29, 2017 09:47 — forked from max-mapper/0.md
JS hoisting by example

JavaScript function hoisting by example

Below are many examples of function hoisting behavior in JavaScript. Ones marked as works successfuly print 'hi!' without errors.

To play around with these examples (recommended) clone them with git and execute them with e.g. node a.js

Notes on hoisting

(I may be using incorrect terms below, please forgive me)

@git-ashish
git-ashish / .block
Created May 1, 2017 13:04 — forked from steveharoz/.block
d3-force testing ground
license: gpl-3.0
height: 1030
scrolling: yes
@git-ashish
git-ashish / README.md
Created May 1, 2017 13:32 — forked from deanmalmgren/README.md
example of how to export a png directly from an svg
@git-ashish
git-ashish / detectDataURL.js
Created July 27, 2017 05:39 — forked from bgrins/detectDataURL.js
Detect if a string is a data URL. Doesn't try to parse it or determine validity, just a quick check if a string appears to be a data URL. See http://jsfiddle.net/bgrins/aZWTB/ for a demo.
// Detecting data URLs
// data URI - MDN https://developer.mozilla.org/en-US/docs/data_URIs
// The "data" URL scheme: http://tools.ietf.org/html/rfc2397
// Valid URL Characters: http://tools.ietf.org/html/rfc2396#section2
function isDataURL(s) {
return !!s.match(isDataURL.regex);
}
isDataURL.regex = /^\s*data:([a-z]+\/[a-z]+(;[a-z\-]+\=[a-z\-]+)?)?(;base64)?,[a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i;
@git-ashish
git-ashish / index.html
Created April 3, 2018 04:52 — forked from jasondavies/index.html
alpha-shapes aka concave hulls in d3
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Alpha-Shapes</title>
<script src="http://mbostock.github.com/d3/d3.min.js"></script>
<script src="http://mbostock.github.com/d3/d3.geom.min.js"></script>
<style type="text/css">
path {
@git-ashish
git-ashish / README.md
Created May 6, 2018 07:28 — forked from ganeshv/.block
Zoomable Treemap Template

Zoomable Treemap

Treemaps for visualizing hierarchical data. Click to zoom to the next level. Click on the top orange band to zoom out. Based on Mike Bostock's Zoomable Treemaps

This template follows pigshell's convention for "gist templates":

  • It is supplied data using postMessage(), as a single object of the form
@git-ashish
git-ashish / README.md
Created May 6, 2018 07:30 — forked from vasturiano/README.md
Zoomable Sunburst with Labels

Adapted from Mike Bostock's Zoomable Sunburst to include arc labels.

Click on any arc to zoom in. Click on the center circle to zoom out. Click on canvas background to reset zoom.

@git-ashish
git-ashish / .block
Created May 7, 2018 14:02 — forked from mbostock/.block
Tree of Life
license: gpl-3.0
height: 960
@git-ashish
git-ashish / .block
Created May 7, 2018 14:14 — forked from mbostock/.block
Radial Tidy Tree
license: gpl-3.0
border: no
height: 1060