Skip to content

Instantly share code, notes, and snippets.

View ArmmGh's full-sized avatar

Arman Ghazaryan ArmmGh

View GitHub Profile
@ArmmGh
ArmmGh / gist:334106d5eb981b720f866a30074b56ae
Created October 29, 2023 01:18
Safe format balance from Wei to Ether with decimals option
import { formatEther } from 'viem'
export const formatBalance = (
balance = 0,
maxDecimalDigits,
noFormat = false,
) => {
const balanceString = noFormat ? balance.toString() : formatEther(balance)
if (balanceString.includes('.')) {
@ArmmGh
ArmmGh / iterator.js
Created December 30, 2021 22:00
Custom Iteration usin Symbol.iterator
var a = [1, 3, 5, 7];
var it = a[Symbol.iterator]();
it.next().value; // 1
it.next().value; // 3
it.next().value; // 5
@ArmmGh
ArmmGh / fibonacci.js
Created December 21, 2021 20:43
Fibonacci with MEMOIZATION
var fibonacci = (function () {
var cache = {};
return function(n) {
// Base case
if(n==0 || n == 1)
return n;
// Recurse only if necessary
ng build --prod --output-path docs --base-href
Filter
app.filter('unsafe', function($sce) { return $sce.trustAsHtml; });
Usage
<ANY ng-bind-html="value | unsafe"></ANY>
var height = document.getElementsByClassName('job');
var maxH = 0;
var arr = [];
var max;
for(var j=0; j<height.length; j++){
maxH = Math.max(maxH, height[j].clientHeight);
arr.push(height[j].clientHeight);
max = Math.max(...arr);
}
console.log('arr ', arr);
@ArmmGh
ArmmGh / gist:5b51a2a12a0c110d8ce602c91a4ccca1
Created April 7, 2017 14:15
background-image and background-color
background: linear-gradient(to right, rgba(0,0,0,.6), rgba(0,0,0,.6)), url(https://i.stack.imgur.com/tgLtG.jpg);
@ArmmGh
ArmmGh / Accordion (only html)
Last active March 18, 2017 12:57
Accordion
<div class="accordion">
<div class="accordion-item">
<div class="accordion-item-title">We build your dream</div>
<div class="accordion-item-content">Content text</div>
</div>
<div class="accordion-item">
<div class="accordion-item-title">Connecting people</div>
<div class="accordion-item-content">Content text</div>
</div>
<div class="accordion-item">
*{
box-sizing: border-box;
-moz-box-sizing: border-box; /*Firefox 1-3*/
-webkit-box-sizing: border-box; /* Safari */
}
div{
box-sizing: border-box;
-moz-box-sizing: border-box; /*Firefox 1-3*/
-webkit-box-sizing: border-box; /* Safari */
}