Skip to content

Instantly share code, notes, and snippets.

View Anenth's full-sized avatar
🎯
Busy building apps people love ❤️

Anenth Anenth

🎯
Busy building apps people love ❤️
View GitHub Profile
@Anenth
Anenth / convertSvgToPng.fish
Created January 19, 2024 16:12
Convert all the svg to png
# Install ImageMagick if not already present
if not command -sq magick
echo "Installing ImageMagick..."
brew install imagemagick
end
# Set the path to the folder containing SVG files
set svg_folder ~/Downloads/path
@Anenth
Anenth / downloadAllImages.js
Last active January 19, 2024 15:44
Download all the image in HTML document
function downloadAllImages(container) {
const imageElements = container.querySelectorAll('img');
if (!imageElements.length) {
console.error('No images found in the container.');
return;
}
for (const imageElement of imageElements) {
const imageUrl = imageElement.src;
@Anenth
Anenth / UserLocationUtils.ts
Created November 10, 2021 04:51
Get IP and Location from the browser js
function getCloudflareJSON(data): Promise<{
fl: string
h: string
ip: string
ts: number
visit_scheme: string
uag: string
colo: string
http: string
loc: string
@Anenth
Anenth / select option styles.css
Created March 27, 2021 06:06
Style browser <select/> <option/>
select {
display: block;
font-size: 12px;
font-family: sans-serif;
font-weight: 600;
color: #4d6178;
line-height: 14px;
padding: 8px 12px 8px 8px;
width: 100%;
max-width: 100%;
@Anenth
Anenth / Table with fixed-data-table-2.js
Created May 18, 2020 06:32
Table with fixed-data-table-2
import React, { useState } from 'react';
import ClassNames from 'classnames';
import { Table as FixedTable, Column } from 'fixed-data-table-2';
import '!!style-loader!css-loader!fixed-data-table-2/dist/fixed-data-table-base.css';
import { get } from 'lodash';
import { ellipseString } from '../../helpers/BaseUtils';
import { HTML_ICON, Icon, ICON_SIZES } from '../Icons/Icons';
import { Text, TEXT_SIZE } from '../Text/Text';
import { Tooltip } from '../Tooltip/Tooltip';
@Anenth
Anenth / Simple data watcher.js
Created December 18, 2018 03:48
A simple pub/sub model - `set data()` - whenever this.data is changed the `set data()` gets called
function Store(initialData, options = {}) {
const handlers = [];
let nextHandlerId = 0;
return {
get data() {
return initialData;
},
set data(t) {
console.log("Set was called");
@Anenth
Anenth / Arraymultiple.js
Created November 14, 2018 04:54
Array multiple with prototype
Array.prototype.multiply = function(){
const le = this.length;
for(let i=0; i < le; i++){
this[i+le] = this[i]*this[i];
console.log(this)
}
};
const a = [1, 2, 3, 4, 5];
a.multiply();
@Anenth
Anenth / cancellable_promise-bluebird.js
Created December 11, 2017 14:33
Cancellable promise with bluebird
import Promise from 'Bluebird';
function updateUser() {
return new Promise((resolve, reject, onCancel) => {
let cancelled = false;
// you need to config Bluebird to have cancellation
// http://bluebirdjs.com/docs/api/promise.config.html
onCancel(() => {
cancelled = true;
@Anenth
Anenth / cancellable_promise.js
Created September 21, 2017 14:52
Cancellable promise
export const CancellablePromise = (promise) => {
let isCancelled = false;
const wrappedPromise = new Promise((resolve, reject) => {
promise.then(
(...args) => (isCancelled ? reject('cancelled') : resolve(...args)),
error => (isCancelled ? reject('cancelled') : reject(error)),
);
});
@Anenth
Anenth / 0_reuse_code.js
Created September 3, 2017 06:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console