Skip to content

Instantly share code, notes, and snippets.

View pi0's full-sized avatar
๐Ÿ‘€

Pooya Parsa pi0

๐Ÿ‘€
View GitHub Profile
@pi0
pi0 / get_locales.js
Last active September 30, 2017 07:47
// https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
function get_locales() {
let all = document.getElementsByTagName('pre')[0].innerText
let regex = /Subtag: (.*)/
let match
let matches = []
while(match = regex.exec(all)) {
matches.push(match[1])
}
  • The benchmarks used by Marko, with one benchmark containing only a single component with ~50 lines of code, and the other 3 components with one of them fully static markup, are typical micro-benchmarks created to the advantage of certain implementation details. They are too isolated and too trivial to justify across-the-board performance claims.

  • For client-side performance I recommend using the 3rd party js-framework-benchmark as a more neutral reference; the benchmark tests a much bigger workload and covering a much more comprehensive performance scenarios. According to the data from the latest round Vue actually outperforms Marko. That said, even this benchmark doesn't reflect real world performance where much more overhead comes from big component trees.

  • Vue has significantly improved SSR performance for

@pi0
pi0 / .dockerignore
Last active August 29, 2018 21:04
Multi Stage Docker Builds for Node.js
node_modules
html {
direction: rtl;
}
body {
direction: rtl;
}
.text-left {
text-align: right;
@pi0
pi0 / plugin.js
Last active August 25, 2017 22:59
Nuxt Middleware Using Modules
import middleware from '~/.nuxt/middleware'
middleware.auth = function ({ store }) {
console.log('Auth middleware!')
}
/*
Notes:
- Nuxt modules can provide plugins: https://nuxtjs.org/guide/modules#provide-plugins
- Do not write stateful code that relies on global context or you will get into trouble with SSR
@pi0
pi0 / proposal.md
Last active August 4, 2017 09:34
git-pr

git-pr

(Based on a tweet by chrisvfritz)

A simple CLI tool for working with PR forks

  1. With git-pr, We can checkout with:
# Checkout in pr/123 branch
@pi0
pi0 / aliasthat.sh
Created June 13, 2017 09:49 — forked from znck/aliasthat.sh
Create an alias for last command.
function aliasthat {
if [ -n ${1} ]; then
fc -e "sed -i -e \"s/^.*/echo alias $1=\\\"'\\\"\'&\'\\\"'\\\" >> ~\/.bash_alias/\""
. ~/.bash_alias
fi
}
@pi0
pi0 / CKEditor.vue
Created June 2, 2017 15:12
CKEditor
<!-- Based on https://github.com/dangvanthanh/vue-ckeditor -->
<template>
<div class="ckeditor">
<textarea :id="id" :value="value"></textarea>
</div>
</template>
<style scoped>
.ckeditor {
@pi0
pi0 / count.js
Created May 16, 2017 07:31 — forked from yyx990803/count.js
// $ yarn add request request-promise
// $ node count userA userB
const request = require('request-promise')
const get = resource => request({
url: /^https/.test(resource) ? resource : `https://api.github.com/${resource}`,
headers: {
'User-Agent': 'GitHub Contrib Counter',
'Authorization': 'token YOUR_PERSONAL_ACCESS_TOKEN'
@pi0
pi0 / bootstrap.js
Created May 14, 2017 15:19
Bootstrap Vue Laravel Mix
window._ = require('lodash');
/**
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
* for JavaScript based Bootstrap features such as modals and tabs. This
* code may be modified to fit the specific needs of your application.
*/
window.$ = window.jQuery = require('jquery');