Skip to content

Instantly share code, notes, and snippets.

View ihorbond's full-sized avatar
💻
Coding

Ihor Bodnarchuk ihorbond

💻
Coding
View GitHub Profile
@ihorbond
ihorbond / nuxt.config.js
Created April 13, 2022 21:57
Add a script tag with callback to NuxtJS
head: {
title: 'Zero Code NFT Wizard',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }, // mobile responsive https://search.google.com/test/mobile-friendly
{ name: 'format-detection', content: 'telephone=no' },
{
hid: 'description',
name: 'description',
content: 'Drop your NFT collection with ZERO coding skills',
@ihorbond
ihorbond / wallet.js
Last active December 24, 2022 11:56
Metamask dApp NuxtJS plugin
import Vue from 'vue'
import { ethers } from 'ethers'
import MetaMaskOnboarding from '@metamask/onboarding'
export default async ({env}, inject) => {
const wallet = Vue.observable({
account: null,
accountCompact: null,
network: null,
@ihorbond
ihorbond / setRarities.js
Created December 30, 2021 23:27
Drop this file into your layers folder, set the percentages sorted alphabetically and run with node ./setRarities.js
const fs = require('fs');
const path = require('path')
function validate(basePath) {
console.log("running validation")
Object.entries(percentages).forEach(([key,val]) => {
const folderPath = path.join(basePath, key)
fs.readdir(folderPath, (err, files) => {
@ihorbond
ihorbond / solc-compiler.js
Created December 22, 2021 00:19
Solc compiler js
function findImports(missingImport) {
if (missingImport.startsWith('@openzeppelin')) {
console.log(`reading import ${missingImport}`)
return {
contents: fs.readFileSync(path.join('../node_modules', missingImport), 'utf8')
};
}
else {
console.log(`import ${missingImport} not found`);
return { error: 'File not found' };
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
@ihorbond
ihorbond / GroupByDateTime.cs
Created July 1, 2020 21:16
How to group items by day, week and year
IEnumerable<dynamic> GetGroup()
{
return settings.GroupBy switch
{
GroupByEnum.Day => listOfObjects.GroupBy(x => new DateTime(x.StartDate.Year, x.StartDate.Month, x.StartDate.Day))
.Select(x => new
{
Date = x.Key.ToString("d"),
Items = x
}),
@ihorbond
ihorbond / clamp-text.css
Created July 1, 2020 21:13
Clamp text with ellipsis after certain number of lines
.clamp {
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
@ihorbond
ihorbond / Uploader.cs
Created April 27, 2020 17:32
Upload file anonymously with C#
private static async Task<string> UploadFile(byte[] bytes, string expiresParam = "1d", bool noIndexParam = true)
{
string res = null;
try
{
using (var client = new HttpClient())
using (var formData = new MultipartFormDataContent())
{
formData.Add(new StringContent(noIndexParam.ToString()), "no_index");
formData.Add(new StringContent(expiresParam), "expires");
@ihorbond
ihorbond / EncryptionHelper.cs
Created April 26, 2020 21:25
Encrypt file with BouncyCastle and C#
using Org.BouncyCastle.Bcpg;
using Org.BouncyCastle.Bcpg.OpenPgp;
using Org.BouncyCastle.Security;
using System;
using System.IO;
namespace Helpers
{
public class EncryptionHelper
{
@ihorbond
ihorbond / form-control-decimal.directive.ts
Last active July 1, 2019 14:08
Angular 4 decimal directive
import { Input, Directive, HostListener } from "@angular/core";
import { NgControl } from "@angular/forms";
import { DecimalPipe } from "@angular/common";
/*
* Form control decimal directive.
* Pass optional custom regex and pipe expression.
* */
@Directive({