Navigation Menu

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
version: '3'
services:
postgres:
image: postgres
environment:
POSTGRES_PASSWORD: test1234
POSTGRES_USER: noud
restart: always
ports:
- 5432:5432
@noudadrichem
noudadrichem / sliceOutValues.js
Last active April 8, 2019 13:04
filter double multiple values from array
const filteredArray = arr => arr.filter((item, idx, arr) => arr.indexOf(item) === idx)
@noudadrichem
noudadrichem / split array in 2
Created April 21, 2019 22:18
splits an array in 2
function getSplittedArray(arr) {
const first = arr.length % 2 === 0
? arr.splice(0, (arr.length/2))
: arr.splice(0, (arr.length/2 + 1))
const second = arr
return [first, second]
}
SELECT [email_column], SUBSTRING([email_column], POSITION('@' IN [email_column]) + 1) AS domain_name
FROM [table]
-- 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,
@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;
}
Math.floor(Math.random() * 16777215).toString(16)
@noudadrichem
noudadrichem / ultra-unique-id.js
Created January 10, 2019 22:36
Returns a id string with a timestamp in it
const timestamp = (new Date().getTime() / 1000 | 0).toString(16);
const uniqueTimeStampId = (stamp) => stamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, () => (Math.random() * 16 | 0).toString(16)).toLowerCase()