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
SELECT [email_column], SUBSTRING([email_column], POSITION('@' IN [email_column]) + 1) AS domain_name
FROM [table]
@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]
}
version: '3'
services:
postgres:
image: postgres
environment:
POSTGRES_PASSWORD: test1234
POSTGRES_USER: noud
restart: always
ports:
- 5432:5432
@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()
const nav = document.querySelector('#nav');
const topOfNav = nav.offsetTop
function fixNav() {
if(window.scrollY >= topOfNav) {
document.body.classList.add('fixed-nav')
document.body.style.paddingTop = nav.offsetHeight + 'px';
} else {
document.body.classList.remove('fixed-nav')
document.body.style.paddingTop = 0;
@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)
" Vim color file
" Converted from Textmate theme City Lights using Coloration v0.4.0 (http://github.com/sickill/coloration)
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGKyxYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKcHCBMZHSQoVSRudWxs1QkKCwwNDg8QERJcTlNDb21wb25lbnRzVU5TUkdCXE5T
Q29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29sb3JTcGFjZVYkY2xhc3NPECgwLjIwNzg0MzEz
NzMgMC4yNDcwNTg4MjM1IDAuMjg2Mjc0NTA5OCAxTxAnMC4xNTc1NDY3NDM4IDAuMTg4
@noudadrichem
noudadrichem / wp-docker-compose.yml
Last active January 29, 2021 11:03
Wordpress in Docker
version: '2'
services:
wordpress:
depends_on:
- db
image: wordpress:4.7.1
restart: always
volumes:
- ./wp-content:/var/www/html/wp-content
environment:
@noudadrichem
noudadrichem / allow-svg-mime-types.php
Created April 28, 2018 07:52
allows SVG mime types in Wordpress, put this snippet in your themes `functions.php` and you're done.
<?php
# mime = meme
function cc_mime_types($memes) {
$memes['svg'] = 'image/svg+xml';
return $memes;
}
add_filter('upload_mimes', 'cc_mime_types');
function fix_svg() {