Skip to content

Instantly share code, notes, and snippets.

View ianfabs's full-sized avatar

Ian Fabs ianfabs

View GitHub Profile
@ianfabs
ianfabs / index.html
Last active September 18, 2018 18:15
A simple, efficient, redirect page to hide directory content 👌 Just slap this bad-boy into the directory you want to hide, then change the content of the META tag to the path you'd like to move to and BLAM - done 😁
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="redirect" content="./path/to/redirect/">
<title>304 Permanent Redirect</title>
</head>
<body>
@ianfabs
ianfabs / jesus_people_are_wild.txt
Created September 20, 2018 15:06
This is a forum i found about people complaining about inspect element and it's REALLY cringy
https://answers.microsoft.com/en-us/ie/forum/ie11-iewindows_10/inspect-element-in-edge-why/64704ef0-4880-44df-b9c2-d90d8a34885d
@ianfabs
ianfabs / setup.sh
Created September 20, 2018 17:01
Just a script to install the things I need for work, since I switch computers a lot
#!/bin/bash
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
# Install repo
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
# Update apt-get
sudo apt-get update
# Install
sudo apt-get install code-insiders
@ianfabs
ianfabs / jraph.ts
Created October 22, 2018 04:29
jraph - a simple fetch wrapper for GraphQL, just to tidy up the look of things!
async function jraph(argv: JraphOptions){
let url = argv.url;
let headers = { 'Content-Type': 'application/json' }
let body = JSON.stringify({query: argv.query});
let fetch_options = {
method: argv.method,
headers,
body
};
//returns request as JSON
@ianfabs
ianfabs / jgraph.ts
Created October 22, 2018 04:18
jgraph: a simple typescript-based fetch api for GraphQL, to make it a bit easier to use semantically
interface JraphOptions{
url: string;
method: "post" | "POST" | "get" | "GET" | "put" | "PUT" | "delete" | "DELETE";
query: string;
}
async function jraph(argv: JraphOptions){
let url = argv.url;
let headers = { 'Content-Type': 'application/json' }
let body = JSON.stringify({query: argv.query});
@ianfabs
ianfabs / objectify.js
Created March 2, 2019 01:56
This function solves an issue i was experiencing on a project where mongoose wasn't correctly returning an object for graphql resolvers. This fixes that issue by returning a new version of the object supplied to the function and converting the object id to a string.
//long version
const objectify = object => (
object.isArray()
?
object.map(element => objectify(element))
:
({
...object.toObject(),
_id: object._id.toString(),
})
@ianfabs
ianfabs / sleep.js
Created March 2, 2019 06:41
A tiny module that implements sleep in javascript
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
module.exports = sleep;
@ianfabs
ianfabs / one-liners.js
Created March 5, 2019 16:10
A collection of lovely one-liners that I use
// A sleep implementation in javascript
const sleep = t => new Promise(r=>setTimeout(r,t));
// A function that rearranges an object returned by mongoose to play nicely with graphql resolvers
const objectify = o => (o.isArray()?o.map(e=>objectify(e)):({...o.toObject(),_id:o._id.toString()}));
@ianfabs
ianfabs / db.js
Last active April 9, 2019 16:54
A really really REAAAALLLY tiny DB I made for testing things, works great with graphql apis :-)
// Do not use this class yet, please just use the Collection class
class DB {
constructor(collections) {
if (
collections !== null &&
collections !== undefined &&
collections !== []
) {
//this._db = collections.map((s, i) => ({ ...s, id: i }));
if (collections instanceof Object) {
#!/bin/bash
RED='\033[0;31m'
BLUE='\033[0;34m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
#Update and install necesary tools
echo "${BLUE}UPDATING AND INSTALLING TOOLS ${NC}\n"
sudo apt update