Skip to content

Instantly share code, notes, and snippets.

View pi0's full-sized avatar
💭
I may be slow to respond.

Pooya Parsa pi0

💭
I may be slow to respond.
View GitHub Profile
@pi0
pi0 / README.md
Last active November 10, 2020 12:45
doNotTrack polyFill

Tiny (230 char) Polyfill for window.doNotTrack. Checks for:

  • window.doNotTrack == 1
  • navigator.doNotTrack == 'yes'
  • navigator.doNotTrack == 1
  • navigator.msDoNotTrack == 1'
  • window.external.msTrackingProtectionEnabled()

And sets value to either 1 (do not track) or 0 (track)

const fs = require('fs')
const axios = require('axios')
callback
fs.readFile('test.txt', 'utf-8', (err, str) => {
if (err) {
console.error('Something bad!' + err)
}
console.log(str)
})
@pi0
pi0 / cms.vue
Last active August 20, 2020 00:57
Vue Universal Runtime Compile
<template>
<div>
<component :is="CMSComponent" :x="x" />
<button @click="x++">
Click on me
</button>
</div>
</template>
<script>
@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 / ConvoySetup.sh
Last active May 7, 2020 16:39
ConvoySetup
# Usage curl -#L https://git.io/convoy | sudo bash
CONVOY_VERSION=v0.5.0
cd /tmp
echo "Downloading convoy ..."
wget -q https://github.com/rancher/convoy/releases/download/$CONVOY_VERSION/convoy.tar.gz -O convoy.tar.gz
echo "Installing convoy ..."

Nuxt functions implementation specs

Initial RFC: nuxt/rfcs#35

This is a Draft

Introducing a functions/ directory could have a powerful effect for users that want to add server functions but without having to go through serverMiddleware Functions can be also provided by Nuxt modules, for example, CMS module or auth provider can add it's functionalities to the user context.

Usage

@pi0
pi0 / WikipediaDump.md
Last active February 27, 2020 14:16
A Dummy Way to Extract Clean Wikipedia Contents

Dump Wikipedia

  • Go to https://dumps.wikimedia.org/backup-index.html
  • Go to language and download -pages-meta-current.xml.bz2 version
  • Extract
  • Flatten with pv file.xml | xml2 > file.flat
  • Exrtract text with pv file.flat| grep -oP "(?<=^/mediawiki/page/revision/text=).*" > file.txt
  • Clean with pv fawiki-20200220-pages-articles.txt | node clean.js
  • Enjoy using out.txt
@pi0
pi0 / git_commit.js
Last active November 18, 2019 14:48
Get git commit in one line!
const gitCommit = process.env.GIT_COMMIT || require('child_process')
.spawnSync('git', ['rev-parse', '--short', 'HEAD'], { encoding: 'utf8' })
.stdout.slice(0, -1)
console.log(gitCommit)
{
// Editor
"diffEditor.renderSideBySide": true,
"editor.fontFamily": "Anonymous, InputMono, Menlo, Monaco, 'Courier New', monospace",
"editor.find.autoFindInSelection": true,
"editor.fontLigatures": true,
"editor.formatOnSave": false,
"editor.formatOnType": true,
"editor.formatOnPaste": true,
@pi0
pi0 / centos.sh
Last active September 27, 2019 11:10
Setup CentOs -- The pro way ;)
# Updates
yum update -y
# Optional deps
yum install -y vim zsh pv nc zip unzip aria2 curl wget rsync
# EPEL
wget dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm -O /tmp/epel.rpm && rpm -ihv /tmp/epel.rpm && rm /tmp/epel.rpm
yum update -y
yum install -y htop