Skip to content

Instantly share code, notes, and snippets.

View lil5's full-sized avatar

Lucian I. Last lil5

View GitHub Profile
@lil5
lil5 / http-error.go
Created June 24, 2021 09:25
Http Error handeling with GoLang Gin
package tools
import (
"net/http"
"github.com/gin-gonic/gin"
)
type HttpErr struct {
Err error
@lil5
lil5 / .bashrc.part
Created May 5, 2021 09:41
Bash with branch
# with color prompt
PS1="\[\033[95m\]\u@\h \[\033[32m\]\W\[\033[33m\] [\$(git symbolic-ref --short HEAD 2>/dev/null)]\[\033[00m\]\$ "
# without
PS1="\u@\h \W [\$(git symbolic-ref --short HEAD 2>/dev/null)]\$ "
@lil5
lil5 / li-woo-shortcode.php
Created March 27, 2021 16:21
Shortcode WooCommerce Product Price.
<?php
/*
Plugin Name: LI Woo Shortcode
Plugin URI: http://li.last.nl
Description: Add Product Price in WooCommerce as a Shortcode
Version: 1.0
Author: Lucian I. Last
Author URI: https://li.last.nl
License: GPL2
@lil5
lil5 / li-sitemap.php
Created March 24, 2021 12:58
Removes unwanted Wordpress sitemaps
<?php
/*
Plugin Name: LI Sitemap
Plugin URI: http://li.last.nl
Description: A very basic sitemap plugin
Version: 1.0
Author: Lucian I. Last
Author URI: https://li.last.nl
License: GPL2
@lil5
lil5 / update-repos.sh
Created November 27, 2020 07:49
Keep up to date with your backend
#!/bin/bash
dirs=("api" "api2")
for d in "${dirs[@]}"
do
pushd $d
git pull
popd
done
@lil5
lil5 / vue-i18n.d.ts
Last active November 16, 2020 08:05
Force vue-i18n to function $t to return string
import VueI18n, {
Path, Values, Locale,
} from 'vue-i18n/types'
/**
* Overloads VueI18n interface to avoid needing to cast return value to string.
* @see https://github.com/kazupon/vue-i18n/issues/410
*/
declare module 'vue-i18n/types' {
export default class VueI18n {
@lil5
lil5 / enum-reflection.ts
Created October 13, 2020 13:13
TypeScript - convert enum to array
/**
* https://dirask.com/posts/TypeScript-convert-enum-to-array-ZDN4nj
*/
class EnumReflection {
private static REGEXP : RegExp = /^[0-9]+$/g;
private static isString<T>(name : string) : boolean {
if(name.match(this.REGEXP))
return false;
@lil5
lil5 / get-obj.ts
Last active September 15, 2020 11:21
Typescript Utils
export function getObj<V>(getObj: () => V): V | undefined {
let value: undefined | V;
let shouldReturnUndefined: boolean = false;
try {
value = getObj();
} catch (e) {
if (e instanceof TypeError) {
shouldReturnUndefined = true;
}
}
@lil5
lil5 / build-scss.bash
Created August 18, 2020 09:29
Build SCSS
#!/bin/bash
for file in $(find . -path ./node_modules -prune -false -o -name "*.scss")
do npx sass ${file}:${file%.scss}.css;
echo $file
done
const copyToClipboard = str => {
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);