Skip to content

Instantly share code, notes, and snippets.

View omar2205's full-sized avatar
πŸ•

omar2205

πŸ•
View GitHub Profile
@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
@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 / 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 / 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 / golang-tls.md
Created March 5, 2019 21:27 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
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 / 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 / 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.