Skip to content

Instantly share code, notes, and snippets.

View KarmaBlackshaw's full-sized avatar
🎃
Haunting

Ernie Jeash Villahermosa KarmaBlackshaw

🎃
Haunting
View GitHub Profile

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@KarmaBlackshaw
KarmaBlackshaw / socket-wilcard.md
Last active January 4, 2021 06:23
Listen for every custom events in a socket

Socket IO Wildcard Listener

Listen for every custom events in a socket

Installation

const onevent = socket.onevent;
socket.onevent = function (packet) {
  const args = packet.data || [];
 onevent.call (this, packet); // original call

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10 001st prime number?

const isPrime = num => {
  const sqrt = Math.sqrt(num)
  for (let i = 2; i <= sqrt; i++) {
    if (num % i === 0) {
 return false
@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'
@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 / 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 / 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 / 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 / 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 / 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