Skip to content

Instantly share code, notes, and snippets.

View omar2205's full-sized avatar
🍕

omar2205

🍕
View GitHub Profile
@omar2205
omar2205 / dailyui-007-settings.markdown
Created January 16, 2018 03:26
#dailyui 007: Settings

#dailyui 007: Settings

Fully responsive and animated settings modal - CSS-only, no Javascript. Got a bit of a design-block so it's a little late!

A Pen by omr on CodePen.

License.

@omar2205
omar2205 / error.php
Created February 1, 2018 15:56
Custom Error Page PHP
/* Custom Error page
by Oscar
*/
<?php
if (!function_exists('http_response_code_title'))
{
function http_response_code_title($code = 403)
{
$title = 'Forbidden';
@omar2205
omar2205 / golang-tls.md
Created March 5, 2019 21:27 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@omar2205
omar2205 / server.js
Created October 31, 2019 11:46
express async fetch
const app = require('express')()
const fetch = require('node-fetch')
const API_KEY = process.env.API_KEY
app.get('/posts', async (req, res) => {
const getPosts = () => fetch(`/api/key=${API_KEY}`)
const processPosts = async () => {
const posts = await getPosts()
const postsJSON = await posts.json()
@omar2205
omar2205 / server.js
Created October 31, 2019 14:04
express logger
const express = require('express')
const app = express()
const log = console.log
const myLogger = (req, res, next) => {
res.on('finish', function() {
log(`${this.statusCode} ${req.method} ${req.path} - ${req.headers['cf-connecting-ip']} `)
}
}
@omar2205
omar2205 / addJs.js
Last active January 31, 2021 17:24
add js and js module script from url
const addJs = url => {
let jsScript = document.createElement('script')
jsScript.setAttribute('src', url)
document.head.appendChild(jsScript)
}
const addJsModule = url => {
let jsScript = document.createElement('script')
jsScript.setAttribute('src', url)
jsScript.setAttribute('type', 'module')
document.head.appendChild(jsScript)
@omar2205
omar2205 / fix_wsl_colors.sh
Last active February 23, 2020 08:40
Fixes WSL (Windows 10 subsystem for linux) weird green colors
#!/bin/bash
# fixes the weird green background for dirs
dircolors -p > ~/.dircolors
# STICKY_OTHER_WRITABLE 30;42
# OTHER_WRITABLE 34;42
sed -i -e 's/STICKY_OTHER_WRITABLE 30;42/STICKY_OTHER_WRITABLE 01;34/g' ~/.dircolors
sed -i -e 's/OTHER_WRITABLE 34;42/OTHER_WRITABLE 01;34/g' ~/.dircolors
bash
{"v":"5.5.9","fr":30,"ip":0,"op":70,"w":200,"h":200,"nm":"menu 2","ddd":0,"assets":[{"id":"comp_0","layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Layer 4 Outlines","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":12,"s":[100]},{"i":{"x":[0.524],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":17,"s":[0]},{"i":{"x":[0],"y":[1]},"o":{"x":[0.999],"y":[0]},"t":50,"s":[0]},{"t":55,"s":[100]}],"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.637],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.524],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":17,"s":[180]},{"i":{"x":[0.362],"y":[1]},"o":{"x":[0.555],"y":[0]},"t":50,"s":[180]},{"t":62,"s":[0]}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.39,"y":1},"o":{"x":0.515,"y":0},"t":4,"s":[100.229,92.646,0],"to":[0,1.5,0],"ti":[0,-1.5,0]},{"i":{"x":0.247,"y":0.247},"o":{"x":0.333,"y":0.333},"t":17,"s":[100.229,101.646,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.376,"y":1},"o":{"x":0.666,"y":0},"t":50,"s":[100.229,101.646,0],"to":[0,-1.5,0],"ti":[0,1.5,0]},{"i":{"x":0
@omar2205
omar2205 / app.js
Last active April 23, 2020 15:49
js simple fade on scroll (Intersection Observer API)
const el = document.querySelector('.el')
let options = {
root: null, // avoiding 'root' or setting it to 'null' sets it to default value: viewport
rootMargin: '0px',
threshold: 0.5
}
let observer = new IntersectionObserver(([entry]) => {
if(entry.isIntersecting) {
@omar2205
omar2205 / app.js
Created June 23, 2020 12:04
react useReducer quick
const initialState = {
counter: 0
}
const counterReducer= (state, event) => {
if (event.type === 'INC') {
return {
...state,
counter: state.counter +1
}