Skip to content

Instantly share code, notes, and snippets.

View pi0's full-sized avatar

Pooya Parsa pi0

View GitHub Profile
@jayjanssen
jayjanssen / semaphore.js
Created May 27, 2011 18:30
Node.js semaphores
var Semaphore = function(callback, context) {
this.semaphore = 0;
this.callback = callback;
this.context = context || this;
};
Semaphore.prototype.increment = function() {
this.semaphore++;
};
// $ 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'
  • 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

// https://www.netlify.com/blog/2017/07/18/http/2-server-push-on-netlify/
const debug = require('debug')('nuxt:netlify-http2-server-push');
const path = require('path');
const glob = require('glob');
const fs = require('fs');
module.exports = function module(moduleOptions) {
// This module is only enabled on production builds
if (this.options.dev) {
@ahbanavi
ahbanavi / amozeshyar_bypass_igap.user.js
Created February 20, 2021 11:05
Bypass Amozeshyar iGap code
// ==UserScript==
// @name Amozeshyar Bypass iGap
// @version 1
// @description Bypass Amozeshyar iGap code
// @author Yedoost
// @match http://stdn.iau.ac.ir/Student/captchaProcess
// @match http://stdn.iau.ac.ir/Student/manageAccount
// @grant none
// ==/UserScript==
@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
@fernando-basso
fernando-basso / proxy.bash
Last active April 25, 2023 06:43
Proxy functions. Place them in $HOME/.bashrc or in a differente file, and then source it from bashrc, or source it manually when needed. The file extension is merely illustrative.
#!/usr/bin/env bash
# gsettings list-recursively org.gnome.system.proxy
# Change de ip address and port number accordingly.
function myProxyOn() {
gsettings set org.gnome.system.proxy mode 'manual' # ' manual / nome / automatic '
gsettings set org.gnome.system.proxy.http host '10.0.0.1'
gsettings set org.gnome.system.proxy.http port 8080
gsettings set org.gnome.system.proxy.https host '10.0.0.1'
@havvg
havvg / ajax-form.js
Created August 1, 2012 13:20
jQuery AJAX form submit with Twitter Bootstrap modal
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
@jniltinho
jniltinho / install_pagespeed_nginx.sh
Last active June 26, 2023 19:41
How to Install Nginx and Google PageSpeed on Debian/Ubuntu
#!/bin/bash
## Install PageSpeed on Debian 8/9 and Ubuntu 16.04 64Bits
## https://www.howtoforge.com/tutorial/how-to-install-nginx-and-google-pagespeed-on-ubuntu-16-04/
## http://nginx.org/en/linux_packages.html
## https://www.modpagespeed.com/doc/build_ngx_pagespeed_from_source
## https://developers.google.com/speed/pagespeed/module/
## Debian ISO: https://cdimage.debian.org/cdimage/archive/8.9.0/amd64/iso-cd/
## No Link abaixo tem o pacote do Nginx para o Debian 8 64Bits
## https://github.com/jniltinho/ispconfig/tree/master/packages/debian/jessie
## Run as root (sudo su)
@ceejbot
ceejbot / esm_in_node_proposal.md
Last active July 17, 2023 02:45
npm's proposal for supporting ES modules in node

ESM modules in node: npm edition

The proposal you’re about to read is not just a proposal. We have a working implementation of almost everything we discussed here. We encourage you to checkout and build our branch: our fork, with the relevant branch selected. Building and using the implementation will give you a better understanding of what using it as a developer is like.

Our implementation ended up differing from the proposal on some minor points. As our last action item before making a PR, we’re writing documentation on what we did. While I loathe pointing to tests in lieu of documentation, they will be helpful until we complete writing docs: the unit tests.

This repo also contains a bundled version of npm that has a new command, asset. You can read the documentation for and goals of that comma