Skip to content

Instantly share code, notes, and snippets.

@meyt
meyt / App.js
Last active Jun 11, 2022
Navigation-back detector for vue@2 vue-router@3 http://codepen.io/barname_nevis/pen/jOZQwby
View App.js
// basic usage
import Vue from 'vue'
import VueRouter from 'vue-router'
import VueNavbackDetector from './vue-navback-detector.js'
const routes = []
const router = new VueRouter({ routes })
Vue.use(VueNavbackDetector, { router })
new Vue({ router }).$mount('#app')
@meyt
meyt / jcal-debian-install.sh
Created May 3, 2022
jcal install script on Debian (tested on debian11)
View jcal-debian-install.sh
#!/bin/bash
sudo apt install -y build-essential autotools-dev automake libtool libreadline-dev
git clone --depth=1 https://github.com/persiancal/jcal.git
cd jcal/sources
bash ./autogen.sh
./configure --prefix=/usr
make
sudo make install
@meyt
meyt / deadbeef-infobar-ng-build.sh
Created Apr 7, 2022
deadbeef infobar-ng plugin build on ubuntu20.04
View deadbeef-infobar-ng-build.sh
#!/bin/bash
# os: ubuntu 20.04
# deadbeef: 1.8.8
#
# run as normal user
wget https://www.deb-multimedia.org/pool/main/d/deadbeef-dmo/deadbeef-plugins-dev_1.8.8-dmo2_all.deb
sudo apt install -y deadbeef-plugins-dev_1.8.8-dmo2_all.deb
sudo apt install -y build-essentials libgtk-3-dev libxml++2.6-dev
@meyt
meyt / raychat.client.js
Created Apr 7, 2022
raychat nuxt plugin
View raychat.client.js
export default function () {
if (process.env.NODE_ENV !== 'production') return
const i = '<CLIENT_KEY>'
const w = window
const l = w.localStorage.getItem('rayToken')
const g = document.createElement('script')
g.async = true
g.src = 'https://app.raychat.io/scripts/js/' + i + '?href=' + w.location.href
if (l) g.src += '&rid=' + l
document.getElementsByTagName('head')[0].appendChild(g)
@meyt
meyt / goftino.client.js
Created Apr 7, 2022
goftino nuxt plugin
View goftino.client.js
export default (ctx) => {
if (process.env.NODE_ENV !== 'production') return
const i = '<CLIENT_KEY>'
const s = 'https://www.goftino.com/widget/' + i
const l = window.localStorage.getItem('goftino_' + i)
const g = document.createElement('script')
g.async = true
g.src = l ? s + '?o=' + l : s
document.getElementsByTagName('head')[0].appendChild(g)
}
@meyt
meyt / intl-strftime.js
Created Apr 3, 2022
famous strftime (linux+python) format implementation in js (intl)
View intl-strftime.js
export function IranLocale () {
const weekdays = 'یک\u200Cشنبه_دوشنبه_سه\u200Cشنبه_چهارشنبه_پنج\u200Cشنبه_جمعه_شنبه'.split('_')
const weekdaysAbbr = 'ی_د_س_چ_پ_ج_ش'.split('_')
const monthNames = ('فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند').split('_')
const monthNamesAbbr = 'فرو_ارد_خرد_تیر_مرد_شهر_مهر_آبا_آذر_دی_بهم_اسف'.split('_')
const intlDate = new Intl.DateTimeFormat('en-US', {
hour12: false,
calendar: 'persian',
numberingSystem: 'arabext',
year: 'numeric',
@meyt
meyt / vite-svg-vue.js
Created Mar 24, 2022
Import SVG as Vue2 component for Vite
View vite-svg-vue.js
// npm i --save-dev vue-template-compiler@2.6.14 vue-template-es2015-compiler@1.9.1 svgo@2.8.0
const fs = require('fs')
const svgo = require('svgo')
const transpile = require('vue-template-es2015-compiler')
const compiler = require('vue-template-compiler')
async function compileSvg (source, id) {
source = compiler.compile(source, { preserveWhitespace: false }).render
source = `module.exports = { render: function () { ${source} } };`
return transpile(source).replace('module.exports =', 'export default')
@meyt
meyt / loading-placeholder.vue
Last active Mar 13, 2022
Vue loading placeholder
View loading-placeholder.vue
<template>
<div :class="classes" :style="styles">
<img :src="imgsrc">
</div>
</template>
<script>
export default {
props: {
width: {
@meyt
meyt / csgo-setup.sh
Last active Mar 6, 2022
Setup CSGO server on linux/ubuntu
View csgo-setup.sh
#!/bin/bash
##
# Setup CSGO Server
#
# os: ubuntu 20.04
##
HOSTNAME="csgo.meyti.ir"
ADMINPASS="adminpass"
@meyt
meyt / AppsScript.js
Created Mar 4, 2022
uptimerobot:webhook > google sheets
View AppsScript.js
function timeConverter(ts){
var a = new Date(ts * 1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;