Skip to content

Instantly share code, notes, and snippets.

View noudadrichem's full-sized avatar
💻
Learning the sh*t out of things

Noud noudadrichem

💻
Learning the sh*t out of things
View GitHub Profile
@noudadrichem
noudadrichem / isColourDarkOrLight.ts
Created September 7, 2020 07:02
Gives back tags based on RGB code if it's light or dark
public isColourDarkOrLight(rgb: number[]): 'light' | 'dark' {
// RGB to HSP equation: http://alienryderflex.com/hsp.html
const [r, g, b] = rgb;
const hsp = Math.sqrt(
0.299 * (r * r) +
0.587 * (g * g) +
0.114 * (b * b)
);
return hsp > 127.5 ? 'light' : 'dark';
}
@noudadrichem
noudadrichem / toSlug.ts
Last active July 22, 2020 12:28
Escape invalid chars in string to create a slug
const toSlug = 'every thing you $ want. To b3 eScaped';
const slug = toSlug.toLowerCase()
.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
.replace(/\s+/g, '-') // collapse whitespace and replace by -
.replace(/-+/g, '-'); // collapse dashes
import * as fs from 'fs';
import * as ffmpeg from 'fluent-ffmpeg';
class VideoConvertService {
public connection: any;
public PATH: string = 'videos';
public async saveVideoToMachine(bannerSetId: string, videoBinaryString: any, extention: string, encoding: string = 'utf-8'): Promise<any> {
const filename = bannerSetId;
const path: string = `${this.PATH}/${filename}.${extention}`;
import React from 'react';
interface TableProps {
data: any[];
headings?: string[]
}
function Table(props: TableProps): JSX.Element {
const { data = [], headings } = props;
Math.floor(Math.random() * 16777215).toString(16)
@noudadrichem
noudadrichem / Logger.java
Created December 9, 2019 16:38
Java utility class to get Logs.
// INTERFACE:
public interface ILogger {
public static void error(String msg, Object obj) {
System.out.println(msg + " " + obj.toString());
}
public static void warning(String msg, Object obj) {
System.out.println(msg + " " + obj.toString());
}
public static void info(String msg, Object obj) {
@noudadrichem
noudadrichem / Logger.java
Created December 9, 2019 16:38
Java utility class to get Logs.
// INTERFACE:
public interface ILogger {
public static void error(String msg, Object obj) {
System.out.println(msg + " " + obj.toString());
}
public static void warning(String msg, Object obj) {
System.out.println(msg + " " + obj.toString());
}
public static void info(String msg, Object obj) {
@noudadrichem
noudadrichem / getRandomString.js
Created October 4, 2019 10:23
Return a random string with custom length from assigned characters
function getRandomString(wishedIdLength) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789=-[]\|';
var charactersLength = characters.length;
for (let i = 0; i < wishedIdLength; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
-- delete
drop table message;
drop table email;
drop table product;
drop table feed;
drop table account;
create table account (
account_id SERIAL PRIMARY KEY not null,
name varchar(255) not null,
docker run -d -p 49160:22 -p 49162:8080 -p 49161 -v oracledb thebookpeople/oracle-xe-11g