Skip to content

Instantly share code, notes, and snippets.

View ChathuraGH's full-sized avatar
☺️
coding

Chathura madusanka ChathuraGH

☺️
coding
View GitHub Profile
@schacon
schacon / gist:1
Created July 15, 2008 18:17
the meaning of gist
This is gist.
There are many like it, but this one is mine.
It is my life.
I must master it as I must master my life.
Without me gist is useless.
Without gist, I am useless.
@davelandry
davelandry / README.md
Last active October 17, 2024 06:40
SVG Text Wrapping

Using d3plus.textwrap, SVG <text> elements can be broken into separate <tspan> lines, as HTML does with <div> elements. In this example, the first column shows normal wrapped text, the second column shows text that is resized to fill the available space, and the third column shows the default SVG behavior.

D3plus automatically detects if there is a <rect> or <circle> element placed directly before the <text> container element in DOM, and uses that element's shape and dimensions to wrap the text. If it can't find one, or that behavior needs to be overridden, they can manually be specified using .shape( ), .width( ), and .height( ).

Featured on D3plus.org

@rachelhyman
rachelhyman / gist:b1f109155c9dafffe618
Last active October 17, 2024 06:32
Github README anchor links

To create anchor links that jump down to different sections of a README (as in an interactive table of contents), first create a heading:
#Real Cool Heading

The anchor link for that heading is the lowercase heading name with dashes where there are spaces. You can always get the anchor name by visiting the README on Github.com and clicking on the anchor that appears when you hover to the left of the heading. Copy everything starting at the #:
#real-cool-heading

Wherever you want to link to your Real Cool Heading section, put your desired text in brackets, followed by the anchor link in parentheses:
[Go to Real Cool Heading section](#real-cool-heading)

@nolanlawson
nolanlawson / index.html
Created October 17, 2020 21:30
emoji-picker tooltip example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>emoji-picker tooltip demo</title>
<style>
.tooltip:not(.shown) {
display: none;
}
</style>
@mattirish
mattirish / conda_symlink.md
Last active November 5, 2024 19:13
Easily move a conda environment to a different drive on Windows without touching with conda
@documentprocessing
documentprocessing / add-annotations-to-images-in-javascript-using-annotorious-library.html
Last active September 2, 2024 12:24
Add annotations to images manually or automatically using JSON in JavaScript using Annotorious Library. Check https://products.documentprocessing.com/annotation/javascript/annotorious/ for more details.
<html>
<head>
<!-- Linking Annotorious Stylesheet -->
<link rel="stylesheet" href="dist/annotorious.min.css">
<!-- Integrating Annotorious JavaScript Library -->
<script type="text/javascript" src="dist/annotorious.min.js"></script>
</head>
<body>
@ChathuraGH
ChathuraGH / SortToArrar.js
Last active November 30, 2023 10:36
Sort Js Dictionary to Array
var dict = {
"x": 1,
"y": 6,
"z": 9,
"a": 5,
"b": 7,
"c": 11,
"d": 17,
"t": 3
};
@ChathuraGH
ChathuraGH / SortToDic.js
Created November 30, 2023 10:45
Sort Dictionary to Dictionary Js
function sort_object(obj) {
items = Object.keys(obj).map(function(key) {
return [key, obj[key]];
});
items.sort(function(first, second) {
return second[1] - first[1];
});
sorted_obj={}
$.each(items, function(k, v) {
use_key = v[0]
@ChathuraGH
ChathuraGH / SortToDic.js
Created November 30, 2023 10:57
Dictionary sort to Dictionary js
class DictUtils {
static entries(dictionary) {
try {
//ECMAScript 2017 and higher, better performance if support
return Object.entries(dictionary);
} catch (error) {
@ChathuraGH
ChathuraGH / OccCounter.js
Created December 1, 2023 00:39
Character Occurrences Counter of a string
let s = 'hello';
var result = [...s].reduce((a, e) => { a[e] = a[e] ? a[e] + 1 : 1; return a }, {});
console.log(result); // {h: 1, e: 1, l: 2, o: 1}