Skip to content

Instantly share code, notes, and snippets.

View dfa1234's full-sized avatar

David Faure dfa1234

  • NDA
  • Israel
  • 15:53 (UTC +03:00)
View GitHub Profile
@dfa1234
dfa1234 / npx command to run angular cli
Created May 13, 2024 11:37 — forked from ddieppa/npx command to run angular cli
This is the npx command to run angular cli new project without install it globally
npx -p @angular/cli ng new hello-world-project
then locally can run
npx ng g c hello-world-component
/**
* Better DateTimeFormatOptions types
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat for representation details
*/
export interface DateTimeFormatOptions extends Intl.DateTimeFormatOptions {
localeMatcher?: 'best fit' | 'lookup';
weekday?: 'long' | 'short' | 'narrow';
era?: 'long' | 'short' | 'narrow';
year?: 'numeric' | '2-digit';
// Simple node file to remove fill attribute from svg (for using in angular, mat icon, or other...)
// External libraries needed: "xmldoc": "^1.1.2"
const fs = require('fs');
const xmldoc = require('xmldoc');
const removeFillAttrRecursively = (node)=> {
if(node?.attr?.fill){
delete node.attr.fill;
}
@dfa1234
dfa1234 / bulkCreateCoupons.js
Last active July 1, 2019 11:36
Wix code (Corvid) bulk coupons insert
/**
The corvid doc api is not correct
Actually using the doc we get
Error message: "No coupon type"
Here is the code to fix this:
*/
@dfa1234
dfa1234 / api-generic.ts
Last active June 27, 2019 18:02
generic api for accessing a mongodb collection using rxjs5
import {Request, Response} from "express";
import {
Collection,
DeleteWriteOpResultObject,
InsertOneWriteOpResult,
MongoClient,
ObjectID,
UpdateWriteOpResult
} from "mongodb";
import {dbConf} from "../config";
@dfa1234
dfa1234 / pool-connection.ts
Created August 12, 2018 11:19
Mysql Pool Failsafe Connection
import * as mysql from "mysql";
import {MysqlError, Pool, PoolConnection} from "mysql";
import {dbMysqlConf} from "./config";
const MAX_ATTEMPS = 10;
let attempts = 0;
export const managePoolConnection = (app:any) => new Promise((resolve: (status:string) => void, reject: (status:string) => void) => {
let pool: Pool = mysql.createPool(dbMysqlConf);
@dfa1234
dfa1234 / docker-wordpress.service
Created February 19, 2018 02:57
/etc/systemd/system/docker-wordpress.service
[Unit]
Description=docker-wordpress
Requires=docker.service
After=docker.service
[Service]
Restart=always
WorkingDirectory=/home/dfa1324/docker-wordpress
@dfa1234
dfa1234 / docker-compose.yml
Created February 19, 2018 02:40
Docker compose for wordpress
version: '3.3'
services:
db:
image: mariadb:latest
volumes:
- ./db_data:/var/lib/mysql
ports:
- "3308:3306"
restart: always
@dfa1234
dfa1234 / ngx-indexeddb.ts
Last active June 13, 2020 19:19
Indexed DB usable in Angular
export class AngularIndexedDB {
utils: Utils;
dbWrapper: DbWrapper;
constructor(dbName: string, version: number) {
this.utils = new Utils();
this.dbWrapper = new DbWrapper(dbName, version);
}
openDatabase(version: number, upgradeCallback?: Function) {
@dfa1234
dfa1234 / woo.module.ts
Created February 8, 2018 18:02
Woo Angular Module Wrapper
import { ModuleWithProviders, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Injectable, Inject } from '@angular/core';
import * as WooCommerceAPI from 'woocommerce-api';
//For exporting the service:
//import { WooApiService } from './src/woocommerce.service';
//export * from './src/woocommerce.service';