Skip to content

Instantly share code, notes, and snippets.

View adi518's full-sized avatar
🎯
Focusing

Adi adi518

🎯
Focusing
View GitHub Profile
var awesome
var myFunc = function() {
var awesome
}
var myFunc = function() {}
function myFunc() {}
@adi518
adi518 / 1.js
Created July 2, 2018 20:57
Closures
function myFunc() {}
import isNumber from 'lodash.isnumber'
export function toDevicePixelRatio(size, options = {}) {
const {
ratio = 2,
scale = 1,
even = true
} = options
const evenFactor = even ? 2 : 1
const floatSize = parseFloat(size)
@adi518
adi518 / package.json
Last active July 18, 2018 21:46
Webpack 4 + Babel 7 (Next) bundle configuration boilerplate for Vue components
{
"main": "dist",
"scripts": {
"build": "node_modules/.bin/webpack --config webpack.config.js",
"dev": "node_modules/.bin/webpack --config webpack.config.js --watch"
},
"peerDependencies": {
"vue": "^2.5.2"
},
"devDependencies": {
export function InstallComponentsPlugin(components) {
const nameless = [].concat(components).find(component => !!component.name)
if (nameless) {
return void console.error(`[Install Components Plugin warn]: Component is missing Name in ${nameless.__file}.`)
}
return {
install(Vue) {
[].concat(components).forEach(component => Vue.component(component.name, component))
}
}
<template>
<a v-bind="{ href, target, ariaLabel }" class="github-corner">
<svg
aria-hidden="true"
viewBox="0 0 250 250"
v-bind="{ width, height }"
:style="`fill: ${fillColor}; color:${octoColor}; position: absolute; top: 0; border: 0; right: 0;`">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
<path
class="octo-arm"
<script>
// https://vuejs.org/v2/guide/render-function.html#Functional-Components
// Implementation
export default {
functional: true,
render(h, { slots }) {
return slots().default
}
}
@adi518
adi518 / gist:a8be5e1b436648776da8d2e886f735ab
Created June 16, 2018 13:16 — forked from snowman-repos/gist:3825198
JavaScript: Detect Orientation Change on Mobile Devices
// Listen for orientation changes
window.addEventListener("orientationchange", function() {
// Announce the new orientation number
alert(window.orientation);
}, false);
// Listen for resize changes
window.addEventListener("resize", function() {
// Get screen size (inner/outerWidth, inner/outerHeight)