Skip to content

Instantly share code, notes, and snippets.

@trungvose
trungvose / nx-structure-angular-nestjs.md
Last active May 18, 2024 15:37
Nx workspace structure for NestJS and Angular

Nx

https://nx.dev/

Nx is a suite of powerful, extensible dev tools to help you architect, test, and build at any scale — integrating seamlessly with modern technologies and libraries while providing a robust CLI, caching, dependency management, and more.

It has first-class support for many frontend and backend technologies, so its documentation comes in multiple flavours.

Principles

@jspiro
jspiro / README.md
Last active October 29, 2023 23:37
How I do my bitcoin taxes

TurboTax has no crypto support, it also doesn't support importing CSVs of transactions, and CreditKarma has no ability to import from financial institutions at all (so e.g. wealthfront is an instant dealbreaker for trying it). Square sends out terrible CSVs of transactions and does very little to help you report for the few bucks you made.

  1. Import transactions to https://app.koinly.io/transactions
  2. Set tax basis to LIFO, print https://app.koinly.io/reports/2019 to PDF
  3. Load https://app.koinly.io/transactions?page=1 and find the transactions JSON transfer in the Network tab, Copy as cURL
  4. In the terminal, paste this, and either remove the gzip line or pipe through gzip, do this for each page, e.g.:
curl 'https://api.koinly.io/api/transactions?page=1&per_page=20' \
    -XGET \
    -H 'Accept: application/json, text/plain, */*' \
@aelbore
aelbore / esm-cjs-modules.md
Last active May 5, 2024 03:07
Publish your npm package as ES Module, and backward compatibility CommonJS

Create your library

  • Initialize project npm init -y
  • Create esm module ./src/esm/my-lib.js
    function addNumber(value, value2) {
      return value + value2;
    }
    
    export { addNumber };
@gokman
gokman / multiple angular app configuration for nginx
Created December 30, 2019 11:48
multiple angular app configuration for nginx
1. build app1 project with prod flag
ng build --prod
2. copy files under dist folder to the server
scp -r dist/app1/* {username}@{ip address of server}:/var/www/app1/
3. set base href of application (app1 works on /)
<base href="/">
4. build app2 project with prod flag
@drovani
drovani / auth0-rule-shopify-multipass.js
Last active January 30, 2024 19:52
Auth0 Rule to Generate a Multipass token and redirect the user back to the Shopify store
function (user, context, callback) {
if (context.clientMetadata && context.clientMetadata.shopify_domain && context.clientMetadata.shopify_multipass_secret)
{
const RULE_NAME = 'shopify-multipasstoken';
const CLIENTNAME = context.clientName;
console.log(`${RULE_NAME} started by ${CLIENTNAME}`);
const now = (new Date()).toISOString();
let shopifyToken = {
email: user.email,
@jorisvddonk
jorisvddonk / ApolloComplexityPlugin.ts
Last active October 9, 2022 23:01
ApolloComplexityPlugin
import { ApolloServerPlugin, GraphQLServiceContext } from "apollo-server-plugin-base";
import { GraphQLSchema, separateOperations } from "graphql";
import { fieldConfigEstimator, getComplexity, simpleEstimator } from "graphql-query-complexity";
export class ApolloComplexityPlugin implements ApolloServerPlugin {
private schema: GraphQLSchema;
constructor(private maxComplexity: number) { }
public serverWillStart(service: GraphQLServiceContext) {
@CSTDev
CSTDev / Jenkinsfile
Last active January 9, 2023 04:32
Monorepo Jenkinsfile and groovy script that will create a Multi-branch pipeline for each project that has a Jenkinsfile within your repository, put at the top level of your repo and create a job in Jenkins that runs the Jenkinsfile. Useful for when you're using a monorepo and have multiple Jenkinsfiles in multiple sub directories. This can still…
pipeline {
agent {
label 'docker'
}
stages{
stage('Create jobs'){
steps{
container('docker'){
script{
import { Injectable } from "@angular/core";
import { Store } from "@ngrx/store";
import { StoreService } from "./store-service.ts"
import { myReducer, IMyState, } from "./reducer.ts"
@Injectable()
export class SomeService {
constructor(private store: Store<any>, storeService: StoreService) {
// Add the service specific reducers to the set of existing reducers.
storeService.addReducers({myReducer});
@DaniSancas
DaniSancas / neo4j_cypher_cheatsheet.md
Created June 14, 2016 23:52
Neo4j's Cypher queries cheatsheet

Neo4j Tutorial

Fundamentals

Store any kind of data using the following graph concepts:

  • Node: Graph data records
  • Relationship: Connect nodes (has direction and a type)
  • Property: Stores data in key-value pair in nodes and relationships
  • Label: Groups nodes and relationships (optional)
@wkwiatek
wkwiatek / app-1.spec.ts
Last active December 17, 2021 01:52
Angular 2 test snippets for Angular final version. Codebase for https://developers.livechatinc.com/blog/category/programming/angular-2/
// App
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: '<span>{{ sayHello() }}</span>',
})
export class App {
public name: string = 'John';