Skip to content

Instantly share code, notes, and snippets.

Avatar
💚

pooya parsa pi0

💚
View GitHub Profile
@pi0
pi0 / ResumeCreator.js
Last active Jun 28, 2018 — forked from farzadso/No mutations at all
This is what I call clean coding
View ResumeCreator.js
import assert from 'assert';
updateStepFourProps(type, operation, id) {
assert(Array.isArray(this.state[type]), `Cannot do operation on type '${type}'`)
switch (operation) {
case 'add':
this.setState({
[type]: this.state[type].concat(id)
})
@pi0
pi0 / lodash.get.js
Last active Feb 1, 2018 — forked from harish2704/lodash.get.js
Simple lodash.get function in javascript
View lodash.get.js
/**
* getProp - Simple lodash.get implementation
* @author @harish2704, @muffypl, @pi0
* @param {Object} object
* @param {String|Array} path
* @param {*} defaultVal
*/
function getProp (object, path, defaultVal) {
const _path = Array.isArray(path)
? path
View marko-perf.md
  • 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 / aliasthat.sh
Created Jun 13, 2017 — forked from znck/aliasthat.sh
Create an alias for last command.
View aliasthat.sh
function aliasthat {
if [ -n ${1} ]; then
fc -e "sed -i -e \"s/^.*/echo alias $1=\\\"'\\\"\'&\'\\\"'\\\" >> ~\/.bash_alias/\""
. ~/.bash_alias
fi
}
View 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'
View simple-sync-posix-hexdumper.c
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@pi0
pi0 / README.md
Created Dec 18, 2016 — forked from joyrexus/README.md
Form/file uploads with hapi.js
View README.md

Demo of multipart form/file uploading with hapi.js.

Usage

npm install
npm run setup
npm run server

Then ...

@pi0
pi0 / GitHub protocol comparison.md
Created Nov 29, 2016 — forked from grawity/GitHub protocol comparison.md
A comparison of protocols offered by GitHub (for #git on Freenode).
View GitHub protocol comparison.md

Primary differences between SSH and HTTPS. This post is specifically about accessing Git repositories on GitHub.

Protocols to choose from when cloning:

plain Git, aka git://github.com/

  • Does not add security beyond what Git itself provides. The server is not verified.

    If you clone a repository over git://, you should check if the latest commit's hash is correct.

View Modelsim Altra - Ubuntu
#!/bin/bash
#TODO : install setup.run to /opt ...
ALTERA_PATH=/opt/altera/*/
#32bit_deps
sudo dpkg --add-architecture i386
sudo apt-get update
View cake_helper_code_completion.php
<?php
/**
* CakePHP Helper Code Completion
* @author junichi11
*
* install NetBeans 7.0 && cakephp-netbeans plugin
* http://netbeans.org
* https://github.com/evilbloodydemon/cakephp-netbeans/tree/autocomplete
* /path/to/yourproject/nbproject/cake_helper_code_completion.php
*