Skip to content

Instantly share code, notes, and snippets.

@comficker
comficker / PX2CM.js
Last active September 4, 2020 05:06
Convert Pixels to Cm
function px2cm(px, dpi) {
return px * 2.54 / dpi
}
console.log(px2cm(1, 268))
@comficker
comficker / HEX2RGB.js
Created June 6, 2018 01:16
Bellow are javascript code can convert hex to rgb color. Demo: http://aiconverter.com/color/hex-to-rgb
function HEX2RGB (hex) {
"use strict";
if (hex.charAt(0) === '#') {
hex = hex.substr(1);
}
if ((hex.length < 2) || (hex.length > 6)) {
return false;
}
var values = hex.split(''),
r,
@comficker
comficker / chain_list.json
Last active June 10, 2022 09:28
Chain List
[
{
"name": "Ethereum Mainnet",
"rpc": [
"https://cloudflare-eth.com"
],
"shortName": "ethereum-mainnet"
},
{
"name": "Binance Smart Chain Mainnet",
The position property specifies the type of positioning method used for an element (static, relative, fixed, absolute or sticky).
- Position: `position: static | relative | absolute | fixed | sticky`
- Position Properties: `top | right | bottom | left `
- Float Element: `float: left | right | none`
- Clear Floating Elements: `clear: none | left | right | both`
- Index: `z-index: 3 | auto | inherit`
[CSS Cheat Sheet](https://simplecheatsheet.com/tag/css-cheat-sheet/)
@comficker
comficker / Install mochaJS.md
Created October 11, 2022 04:23
Mocha Installation
$ npm install mocha
$ mkdir test
$ $EDITOR test/test.js # or open with your favorite editor

Mocha Cheat Sheet

// Requiring lodash library
const _ = require('lodash');
// Using _.debounce() method
// with its parameters
var debounce_fun = _.debounce(function () {
console.log('Function debounced after 1000ms!');
}, 1000);
debounce_fun();
window.addEventListener('dragover', function(e) {
e.stopPropagation();
e.preventDefault();
});
window.addEventListener('drop', function(e) {
e.stopPropagation();
e.preventDefault();
if(e.dataTransfer.files.length === 0) {
return alert("Seems like you tried to drag-and-drop an image from another browser window? You need to download the image to your computer (right-click, then save image) and then drag-and-drop the downloaded image. Sorry!");
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="">
<meta property="og:type" content="">
@comficker
comficker / docker-compose.yaml
Last active December 15, 2023 07:18
Example Docker Compose .yaml file
version: "3"
services:
redis:
image: redis:alpine
ports:
- "6379"
networks:
- frontend
deploy:
@comficker
comficker / docker-compose-static-web.yaml
Last active December 15, 2023 07:31
docker compose for static web yaml
version: '3.7'
services:
web:
image: nginx:alpine
ports:
- "8000:80"
volumes:
- ./app:/usr/share/nginx/html