Skip to content

Instantly share code, notes, and snippets.

View KarmaBlackshaw's full-sized avatar
🎃
Haunting

Ernie Jeash Villahermosa KarmaBlackshaw

🎃
Haunting
View GitHub Profile
@KarmaBlackshaw
KarmaBlackshaw / generate-ssh-key.md
Last active June 2, 2024 17:27
Generate SSH Key for Github

Generate SSH Key in your server

ssh-keygen -t ed25519 -C "[email]" -f ~/.ssh/[name]

Copy the key in the .pub file and paste it in your gh access tokens

$ cat ~/.ssh/id_ed25519.pub
# Then select and copy the contents of the id_ed25519.pub file
# displayed in the terminal to your clipboard
@KarmaBlackshaw
KarmaBlackshaw / eslintrc.js
Last active October 24, 2024 07:09
Nuxt Eslint Globals
module.exports = {
root: true,
env: {
node: true,
browser: true
},
globals: {
define: true
const chalk = require('chalk')
const { log } = console
const cwd = process.cwd()
function proxiedLog (...args) {
const line = (((new Error('log'))
.stack.split('\n')[2] || '…')
.match(/\(([^)]+)\)/) || ['not found'])[1]
const stack = line
@KarmaBlackshaw
KarmaBlackshaw / eslint-api.md
Last active January 30, 2023 10:27
ESLint Configurations

Eslint Configuration for API

Config

module.exports = {
  env: {
    browser: true,
    commonjs: true,
    es6: true,
    node: true
@KarmaBlackshaw
KarmaBlackshaw / on-click-outside.js
Created June 14, 2022 08:17
Vue 2 Directive: Click Outside
directives: {
clickOutside: {
bind: function (el, binding, vnode) {
el.clickOutsideEvent = function (event) {
// here I check that click was outside the el and his children
if (!(el == event.target || el.contains(event.target))) {
// and if it did, call method provided in attribute value
if (typeof binding.value === 'function') {
binding.value()
}
@KarmaBlackshaw
KarmaBlackshaw / register-base-components.js
Created June 14, 2022 07:19
Vue2 Register Base Components Plugin
import upperFirst from 'lodash/upperFirst'
import camelCase from 'lodash/camelCase'
export default {
install: (Vue, options) => {
const requireComponent = require.context('../components', false, (/Base[A-Z]\w+\.(vue|js)$/))
requireComponent.keys().forEach(fileName => {
// Get component config
const componentConfig = requireComponent(fileName)
@KarmaBlackshaw
KarmaBlackshaw / readme.md
Created May 5, 2022 10:26 — forked from loilo/readme.md
Sass Dark/Light Theme Mixin

Sass Dark/Light Theme Mixin

This is a Sass mixin to handle a 3-way dark mode. It relies on a data-theme attribute on your <html> element with a value of light or dark. If data-theme is absent (i.e. it's neither light nor dark), the system's preferred mode is used.

body {
  // matches data-theme="light" or data-theme="auto" with system instructing light mode
  @include light {
    background: white;
    color: black;
@KarmaBlackshaw
KarmaBlackshaw / email.js
Last active June 14, 2022 08:18
A basic implementation of Email services in javascript
import email from 'emailjs-com'
const serviceId = '' /* your service id */
const templateId = '' /* your template id */
const userId = '' /* your user id */
export default {
/**
* from_name
* from_email
@KarmaBlackshaw
KarmaBlackshaw / default-node-eslint.js
Last active March 2, 2021 05:45
Lint Configurations
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true,
node: true,
},
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
@KarmaBlackshaw
KarmaBlackshaw / mysql.md
Last active March 11, 2022 14:20
List of MySQL Basic Use Cases

List of MySQL Basic Use Cases

BULK UPDATE

When updating multiple rows with different values it is much quicker to use a bulk update.

UPDATE people 
SET name = 
  (CASE 
 WHEN id = 1 THEN 'Karl'