Skip to content

Instantly share code, notes, and snippets.

View highercomve's full-sized avatar
🏠
Working from home for Pantacor 👍

Sergio Marin highercomve

🏠
Working from home for Pantacor 👍
View GitHub Profile
// this file is not scope. You must use it inside a anonymus function and save in windows RandomList and RandomList2 or export those
function createWeightedList (list, weight) {
var weighed_list = [];
for (var i = 0; i < weight.length; i++) {
var multiples = weight[i] * 100;
for (var j = 0; j < multiples; j++) {
weighed_list.push(list[i]);
}
}
import _chain from 'pipeable'
function WorkerWrapper () {
var poster = function (data) {
importScripts(data.funcFileUrl)
data.params.length = Object.keys(data.params).length
postMessage(workerCallBack.apply(null, Array.from(data.params)))
}
onmessage = function (e) {
poster(e.data)
@highercomve
highercomve / hook.js
Last active February 14, 2019 14:51
Creating Form validations with hooks
export default function useValidatedForm (fields = {}, descriptors = [], validators = ValidaJS.validators) {
const initialErrorsObj = emptyErrorFactory(fields)
const initialState = stateFactory(fields)
const [state, setState] = useState(initialState)
const [validation, setValidation] = useState({ valid: true, errors: initialErrorsObj })
const rulesBy = rulesByNameFactory(descriptors, validators)
const form = formDataFactory(state, setState, setValidation, validation, rulesBy)
const getData = () => getDataFromState(state)
const setData = (data) => setState(stateFactory(data))
import React from 'react'
import useValidatedForm from 'react-valida-hook'
const initialState = {
firstName: '',
lastName: '',
email: ''
}
const validations = [
import React from 'react'
import useValidatedForm from 'react-valida-hook'
const initialState = {
firstName: '',
lastName: '',
email: ''
}
const validations = [
import React, { useState } from 'react'
import ReactDOM from 'react-dom'
function UserForm () {
const [errors, setErrors] = useState({})
const submit = (event) => {
event.preventDefault()
const form = event.target
const isValid = form.checkValidity() // returns true or false
const compose = (fn, ...funcs) => {
return (...args) => {
return funcs.reduce((acc, func) => func(acc), fn(...args))
}
}
const generate = (fn, dependency = LazyIterable, descriptor) => {
return Object.create(
Object.assign({ [Symbol.iterator]: fn }, dependency),
descriptor
@highercomve
highercomve / content.json
Last active May 10, 2024 17:58
highercomve.github.io content managment
{
"name": "Sergio Marin",
"nick_name": "highercomve",
"tagline": "I'm a software engineer focused on web applications",
"location": "Santiago, Chile",
"networks": [
{
"title": "Sergio Marin's Github page",
"url": "https://github.com/highercomve",
"icon": "github"
@highercomve
highercomve / fp.helpers.js
Last active May 10, 2019 22:43
Small library for functional helpers.
function filterIterable (filter, iterable) {
const result = [];
const entries = getEntries(iterable);
for (const [key, value] of entries) {
if (filter(value, key)) {
result.push(value);
}
}
return result;
}

PVR install from docker images

Script to install pantahub pvr from source using docker tag (default: latest), the script build the CLI from the source for the current platform and install it on ~/bin/pvr.

How to use it

curl -o- -L https://git.io/fjEI1 | bash