Skip to content

Instantly share code, notes, and snippets.

View thetutlage's full-sized avatar
🏠
Working from home

Harminder Virk thetutlage

🏠
Working from home
View GitHub Profile
@thetutlage
thetutlage / models.js
Created June 27, 2018 09:57
Adonis Lucid entities
const Model = use('Model')
class User extends Model {
}
class Post extends Model {
}
class Category extends Model {
}
@thetutlage
thetutlage / models.js
Created June 27, 2018 10:11
Lucid models relationships
const Model = use('Model')
class User extends Model {
posts () {
return this.hasMany('App/Models/Post')
}
}
class Post extends Model {
author () {
@thetutlage
thetutlage / get-cat.js
Created June 27, 2018 10:16
Get categories
// Import category model
const Category = use('App/Models/Category')
// Get all categories
const categories = await Category.all()
@thetutlage
thetutlage / .zshrc
Created June 30, 2018 05:31
Rename file extensions from a shell script
function rext () {
if [ $# -lt 3 ]; then
echo 1>&2 "$0 needs 3 arguments as DIR SOURCE_EXT DEST_EXT"
else
for file in "$1"/*.$2; do
mv "$file" "${file%.$2}.$3"
done
fi
}
const { hooks } = require('@adonisjs/ignitor')
hooks.after.httpServer(function () {
const Server = use('Server')
const httpInstance = Server.getInstance()
// do whatever you like
})
@thetutlage
thetutlage / settings.json
Created December 1, 2018 08:42
My VsCode settings.json file
{
"workbench.colorTheme": "Plastic - deprioritised punctuation",
"workbench.statusBar.visible": false,
"editor.fontFamily": "operator mono",
"editor.fontWeight": "300",
"typescript.tsserver.log": "verbose",
"editor.matchBrackets": false,
"editor.renderLineHighlight": "gutter",
"workbench.iconTheme": null,
"editor.lineHeight": 30,
@thetutlage
thetutlage / settings.json
Last active January 27, 2019 08:15
VsCode keep code comment tokens in all grey
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "storage.type.class.jsdoc, punctuation.definition.block.tag.jsdoc, punctuation.definition.bracket.curly.begin.jsdoc, punctuation.definition.bracket.curly.end.jsdoc,variable.other.jsdoc",
"settings": {
"foreground": "#65737eff",
}
}
]
}
@thetutlage
thetutlage / setup.js
Created July 10, 2018 09:18
Adonis Lucid Setup without Adonis framework
const { registrar, ioc } = require('@adonisjs/fold')
const _ = require('lodash')
/**
* Very bare bones implementation of the config provider.
* If you run into issues, then make sure to check the
* implementation in adonis-framework repo
*/
class Config {
constructor (config) {
@thetutlage
thetutlage / generate_key.py
Created May 1, 2019 18:09
Generate k8 secret for private docker registry on ECR (Credits: https://github.com/kubernetes/minikube/issues/366#issuecomment-244617587)
#!/usr/bin/env python
import re
import subprocess
def execute_cmd(cmd):
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
comm = proc.communicate()
if comm[1] != '':
@thetutlage
thetutlage / dimer-markdown.css
Created June 21, 2019 15:05
The dimer theme markdown styling css
:root {
--text-color: #454f5b;
--headings-color: #161d25;
--links-color: #fb2f51;
--lead-text-color: #718096;
--text-font: 'DimerSans', sans-serif;
--headings-font: 'Eina 01', sans-serif;
--pre-font: 'Roboto Mono', monospace;
--alerts-bg: #f1f3f5;
--pre-bg: #1b2b34;