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
# The Lazy Coder's Guide to Programming
## Chapter 1: The Art of Copy-Pasting
### Section 1.1: Ctrl+C, Ctrl+V, Repeat
Programming can be hard. But fear not! With the power of copy-paste, you can conquer any coding challenge without breaking a sweat. Just remember: if it works once, it'll work a thousand times. Who needs original code anyway?
## Chapter 2: Debugging 101: Blame the Compiler
@pi0
pi0 / pagespeed_nginx_ubuntu.sh
Last active July 6, 2023 21:58
Install PageSpeed on Ubuntu Nginx Extras
# Deps
sed -i "s|# deb-src|deb-src|" /etc/apt/sources.list
apt update
export DEPS=" \
build-essential zlib1g-dev libpcre3-dev unzip uuid-dev \
debhelper po-debconf libexpat-dev libgd-dev libgeoip-dev libhiredis-dev \
libluajit-5.1-dev libmhash-dev libpam0g-dev libperl-dev libssl-dev libxslt1-dev quilt"
apt install -y $DEPS
# NXG Pagespeed
@pi0
pi0 / colors
Last active August 4, 2022 17:35
Super Simple Node.js String Colors Support
This snippets add super Simple Node.js String Colors Support.
See here:
http://stackoverflow.com/questions/32474241/node-js-terminal-color
http://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color
@pi0
pi0 / Core files
Created April 19, 2015 15:56
Google translate Offline Language Files
https://dl.google.com/translate/offline/v3/r1/c.zip
https://dl.google.com/translate/offline/v3/r1/profiles.txt
@pi0
pi0 / to-pnpm.mjs
Last active March 15, 2022 20:15
Script to migrate to pnpm
#!/bin/env node
import { existsSync } from 'fs'
import fs from 'fs/promises'
import path from 'path'
import { execSync } from 'child_process'
const LATEST_PNPM = '6.32.3'
const dir = path.resolve(process.argv[2] || '.')
const resolve = (...p) => path.resolve(dir, ...p)
@pi0
pi0 / ssh-proxy.sh
Created September 20, 2018 16:06
SSH-SSH
ssh -vo ProxyCommand='ssh -W %h:%p root@proxy_host' root@dst_host
#!/bin/bash
#TODO : install setup.run to /opt ...
ALTERA_PATH=/opt/altera/*/
#32bit_deps
sudo dpkg --add-architecture i386
sudo apt-get update
@pi0
pi0 / next.config.js
Created March 12, 2021 17:29
Webpackbar with Next.js
const Webpackbar = require('webpackbar')
module.exports = {
webpack: (config, { isServer }) => {
config.plugins.push(new Webpackbar({ name: isServer ? 'server' : 'client' }))
return config
}
}
@pi0
pi0 / hrtime.js
Last active November 15, 2020 02:32
process.hrtime polyfill
(function() {
const nowOffset = Date.now();
const now = () => Date.now() - nowOffset;
global.process.hrtime = global.process.hrtime || ((previousTimestamp) => {
const baseNow = Math.floor((Date.now() - now()) * 1e-3)
const clocktime = now() * 1e-3
let seconds = Math.floor(clocktime) + baseNow
let nanoseconds = Math.floor((clocktime % 1) * 1e9)
if (previousTimestamp) {
@pi0
pi0 / README.md
Last active November 11, 2020 14:32
Nuxt Unattended Config Injection

Nuxt loads configuration from several places and merges. Here is the order: (first has more periority)

  • Config overrides by CLI
  • nuxt.config (format: CJS/MJS/TS can be also wrapped into an async function)
  • .nuxtrc
  • ~/.nuxtrc

In order to automatically inject some configuration without direct modification of nuxt.config, it is possible to use .nuxtrc file.

Thanks to super simpler syntax of rc9 this configuration can be injected via a shell script or package itself.