Skip to content

Instantly share code, notes, and snippets.

View dfa1234's full-sized avatar

David Faure dfa1234

  • NDA
  • Israel
  • 07:17 (UTC +03:00)
View GitHub Profile
@dfa1234
dfa1234 / XORCipher.ts
Last active July 30, 2023 20:39 — forked from sukima/XORCipher.js
A Super simple encryption cipher using XOR and Base64 in JavaScript - Just made the typescript version for angular 4, and I removed the underscore dependency
// XORCipher - Super simple encryption using XOR and Base64
// Usage
// --------
//
// XORCipher.encode("test", "foobar"); // => "EgocFhUX"
// XORCipher.decode("test", "EgocFhUX"); // => "foobar"
//
// Copyright © 2013 Devin Weaver <suki@tritarget.org>
//
// This program is free software. It comes without any warranty, to
@dfa1234
dfa1234 / index.html
Created January 31, 2018 20:04
css magic box
<html>
<head>
<title>Snippets</title>
<style>
body{
margin:0;
}
.container{
display: flex;
justify-content: center;
@dfa1234
dfa1234 / app.component.ts
Created January 31, 2018 20:07
HFO for frame animations
import {AfterViewInit, Component, OnInit, QueryList, ViewChild, ViewChildren} from '@angular/core';
import {Observable, Scheduler} from 'rxjs/Rx';
/**
*
* From Scheduler source code:
*
* @property {Scheduler} queue Schedules on a queue in the current event frame
@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';
@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 / 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 / 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 / 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 / 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 / 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:
*/