Skip to content

Instantly share code, notes, and snippets.

View ruslanguns's full-sized avatar
👨‍💻
copy/pasting some code from stack overflow

Ruslan Gonzalez ruslanguns

👨‍💻
copy/pasting some code from stack overflow
View GitHub Profile
@ruslanguns
ruslanguns / add_secret_to_bitwarden.sh
Created January 15, 2023 20:34 — forked from bepcyc/add_secret_to_bitwarden.sh
How to add secret content (e.g. a private key) to a bitwarden and how to restore it back. Chezmoi template included.
SECRET_NAME=id_rsa
SECRET_PATH=~/.ssh/id_rsa
# store the secret content as an item in bitwarden
echo "{\"organizationId\":null,\"folderId\":null,\"type\":2,\"name\":\"${SECRET_NAME}\",\"notes\":\"$(base64 -w 0 ${SECRET_PATH})\",\"favorite\":false,\"fields\":[],\"login\":null,\"secureNote\":{\"type\":0},\"card\":null,\"identity\":null}" | bw encode | bw create item
bw sync # optional
# retrieve the secret
# assuming a single search result
bw list items --search id_rsa | jq -r '.[0].notes' | base64 -d > ${SECRET_PATH}
# in case you're using chezmoi here's a template that will retrieve that secret automatically
#$cat $(chezmoi source-path ${SECRET_PATH})
import React, { useEffect } from "react";
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";
export const RouterMountDemo = () => {
return (
@ruslanguns
ruslanguns / README.md
Last active January 12, 2021 22:41
nxpm/stack README.md

@nxpm/stack

Introduction

@nxpm/stack is a set of schematics that generates an opinionated full-stack application in a Nx Workspace based on Based on current market cutting edge technologies as an example the PANNG Stack, based on its acronyms (Prisma, Angular, Nest, Nx, GraphQL).

This generator allows you to have built in different advanced configurations such as its monorepo architecture, an authentication system based on the cookie strategy, opt for Tailwind as a utility-first CSS framework or Bootstrap, a built in implementation with graphql-codegen an advance code generator for GraphQL, integration with Docker, Github Actions, automatic testing and much more.

Creating a new project

@ruslanguns
ruslanguns / docker-compose.yml
Last active October 5, 2020 23:38
Basic MySQL Docker Instance
version: '2'
services:
database:
image: mysql:5.6
command: --default-authentication-plugin=mysql_native_password
volumes:
- "./.mysql-data/db:/var/lib/mysql"
restart: always
ports:
- 3306:3306
@ruslanguns
ruslanguns / enumToString.ts
Last active December 27, 2022 08:57
enumToString
/**
* Converts an enum into a String
* @param _enum Enum
* @returns string type
* @gist https://gist.github.com/ruslanguns/d5a6bd9af6bddb77d6b2f2a2fef82748
*/
export const EnumToString = (_enum: object) =>
Object.keys(_enum)
.map(key => _enum[key])
@ruslanguns
ruslanguns / countries.enum.ts
Created March 23, 2020 12:07 — forked from evolkmann/countries.enum.ts
TypeScript Enum Country Codes ISO 3166
// Inspired by https://gist.github.com/kyranjamie/646386d5edc174e8b549111572897f81
export enum Country {
AF = 'Afghanistan',
AX = 'AlandIslands',
AL = 'Albania',
DZ = 'Algeria',
AS = 'American Samoa',
AD = 'Andorra',
AO = 'Angola',
AI = 'Anguilla',
@ruslanguns
ruslanguns / sort-by.pipe.ts
Created March 3, 2020 14:53
Angular pipe to sort an array of ngFor
/*
*ngFor="let c of oneDimArray | sortBy:'asc'"
*ngFor="let c of arrayOfObjects | sortBy:'asc':'propertyName'"
*/
import { Pipe, PipeTransform } from '@angular/core';
import { orderBy } from 'lodash';
@Pipe({ name: 'sortBy' })
export class SortByPipe implements PipeTransform {
@ruslanguns
ruslanguns / slugify.pipe.ts
Last active October 5, 2020 23:44 — forked from coskuncakir/slugify.pipe.ts
Angular Pipe to transform a string into a slug with spanish character support.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'slugify' })
export class SlugifyPipe implements PipeTransform {
transform(input: string): string {
const trChars = {
'áÁ': 'a',
'éÉ': 'e',
'íÍ': 'i',
'óÓ': 'o',
@ruslanguns
ruslanguns / abstract-class.dart
Last active January 24, 2020 00:14
Dart Language Intro
void main() {
final perro = Perro();
perro.emitirSonido();
final gato = Gato();
gato.emitirSonido();
}
@ruslanguns
ruslanguns / query.js
Last active January 12, 2020 03:36
Get stats from MongoDB using Aggregation Pepiline
var pastMonth = new Date();
pastMonth.setMonth(pastMonth.getMonth() - 1); // 1 month ago
var ultimasCargas = [
{ $match: { createdAt: { $exists: true } } },
{ $sort: { createdAt: -1 } },
{ $limit: 5 },
{ $project: { brand: 1, productId: 1, price: 1, status: 1, createdAt: 1 } }
];