Skip to content

Instantly share code, notes, and snippets.

View othercodes's full-sized avatar
🚀
Everything is about the context.

Unay Santisteban othercodes

🚀
Everything is about the context.
View GitHub Profile
@othercodes
othercodes / 11101.py
Last active February 15, 2024 02:21
Small birthday present in python.
#!/usr/bin/python3
# acceptance criteria:
# - works without installing non-standard py3 modules
# - tested on *nix distros
# func ideas stub:
# DONE: fortune http://www.yerkee.com/api (computers science all)
# cat: hey you have your own! go to othercodes./cat http://thecatapi.com/
# pokemon https://pokeapi.co/ https://pokeapi.co/docsv2/#pokemon
@othercodes
othercodes / checkout.sh
Last active October 29, 2020 19:03
Restore git bracnh after git force push.
#!/usr/bin/env bash
#
# Git Branch checkout after force push
#
# Execution:
# $ bash checkout.sh [branch]
sudo chown -R www-data ./
echo "Fetching changes from origin..."
sudo -Hu www-data git fetch -p
@othercodes
othercodes / nextjs-hoc-authorization.js
Created August 27, 2020 10:16 — forked from whoisryosuke/nextjs-hoc-authorization.js
ReactJS - NextJS - A HOC for wrapping NextJS pages in an authentication check. Checks for getInitialProps on the child component and runs it, so you still get SSR from the page. Also includes a user agent for Material UI.
import React, {Component} from 'react'
import Router from 'next/router'
import AuthService from './AuthService'
export default function withAuth(AuthComponent) {
const Auth = new AuthService('http://localhost')
return class Authenticated extends Component {
static async getInitialProps(ctx) {
// Ensures material-ui renders the correct css prefixes server-side
@othercodes
othercodes / mysql-docker.sh
Created March 19, 2020 11:18 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@othercodes
othercodes / Backup, restore postgres in docker container
Last active December 17, 2019 16:14 — forked from gilyes/Backup, restore postgres in docker container
Backup/restore postgres in docker container
# Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
# Restore:
cat your_dump.sql | docker exec -i your-db-container psql -U postgres
@othercodes
othercodes / search.sql
Created November 26, 2019 14:59
Search value in ALL tables from the database.
// https://stackoverflow.com/questions/5350088/how-to-search-a-specific-value-in-all-tables-postgresql
CREATE OR REPLACE FUNCTION search_columns(
needle text,
haystack_tables name[] default '{}',
haystack_schema name[] default '{}'
)
RETURNS table(schemaname text, tablename text, columnname text, rowctid text)
AS $$
begin
FOR schemaname,tablename,columnname IN
@othercodes
othercodes / endpoint-full.sh
Last active September 13, 2019 06:57
Easy setup for dev PHP environments.
#!/usr/bin/env bash
#
# PHP Installer (RH)
#
# Install all PHP versions and some extensions.
#
# Tested on:
# - CentOS Linux release 7.5.1804 (Core)
#
bash <(curl -s https://gist.githubusercontent.com/othercodes/ab66f49f2db94e1f40c2ab86003dc17c/raw/phprhinstaller.sh)
@othercodes
othercodes / vhost.sh
Last active November 12, 2019 09:36
Apache virtual host generator.
#!/usr/bin/env bash
#
# Virtual Host Generator
#
# Apache virtual host generator.
#
# Tested on:
# - CentOS Linux release 7.5.1804 (Core)
# - Ubuntu 16.04.3 LTS
#
@othercodes
othercodes / linkler.sh
Created May 14, 2019 06:53
Migration link generator. Ubuntu
#!/usr/bin/env bash
#
# LINKLER: Migration link generator
#=========================================================
# ██╗ ██╗███╗ ██╗██╗ ██╗██╗ ███████╗██████╗
# ██║ ██║████╗ ██║██║ ██╔╝██║ ██╔════╝██╔══██╗
# ██║ ██║██╔██╗ ██║█████╔╝ ██║ █████╗ ██████╔╝
# ██║ ██║██║╚██╗██║██╔═██╗ ██║ ██╔══╝ ██╔══██╗
# ███████╗██║██║ ╚████║██║ ██╗███████╗███████╗██║ ██║
# ╚══════╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝
@othercodes
othercodes / morphpeus.sh
Created April 15, 2019 08:29
Reconfigure the Apache Mod PHP.
#!/usr/bin/env bash
#
# PHP Mod Apache Installer (RH)
#
# Reconfigure the Apache Mod PHP.
#
# Tested on CentOS Linux release 7.5.1804 (Core)
#
# Execution:
# $ sudo ./morphpeus.sh