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 / transducers.js
Created February 12, 2019 11:44
Transducers POC
const assert = require('assert')
const id = x => x
const compose = (...fns) => fns.reduce((acc, f) => x => acc(f(x)), id)
const add = x => y => x + y
const times = x => y => x * y
const validSubs = x => x > 3
const skus = [1, 2, 3, 4, 5]
@othercodes
othercodes / zion.sh
Created April 15, 2019 08:27
Ion Cube Loaders Installer for Default + RH + Remi
#!/usr/bin/env bash
#
# Ion Cube Loaders Installer for Default + RH + Remi
#
# Automatically install the required Ion Cube Loader
# for the required php version (Default + RH + Remi)
#
# Tested on:
# - CentOS Linux release 7.5.1804 (Core)
# - Ubuntu 16.04.3 LTS
@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 / 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 / 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