Skip to content

Instantly share code, notes, and snippets.

View vigosan's full-sized avatar
🏠
Working from home

Vicent Gozalbes vigosan

🏠
Working from home
View GitHub Profile
@vigosan
vigosan / ffmpeg-compress-mp4
Created March 12, 2024 15:20 — forked from lukehedger/ffmpeg-compress-mp4
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
// TODO: make `pages` optional and measure the div when unspecified, this will
// allow more normal document flow and make it easier to do both mobile and
// desktop.
import {
createContext,
useCallback,
useContext,
useEffect,
useMemo,
useRef,
@vigosan
vigosan / i18n.tsx
Created September 27, 2022 12:41 — forked from madflanderz/i18n.tsx
Simple i18n solution
import React, { useCallback, useMemo } from "react"
import LanguageKeysDe from "./de"
import LanguageKeys, { LangProps } from "./en"
/**
Full example here:
https://codesandbox.io/s/simple-react-typescript-i18n-w0ut6
**/
@vigosan
vigosan / index.js
Created August 9, 2022 12:31 — forked from pinkhominid/index.js
Upload a file with node-fetch and form-data
const fs = require('fs');
const fetch = require('node-fetch');
const FormData = require('form-data');
const filePath = `path/to/file.ext`;
const form = new FormData();
const stats = fs.statSync(filePath);
const fileSizeInBytes = stats.size;
const fileStream = fs.createReadStream(filePath);
form.append('field-name', fileStream, { knownLength: fileSizeInBytes });
@vigosan
vigosan / getWeeksInMonth.js
Created March 22, 2022 07:05 — forked from markthiessen/getWeeksInMonth.js
JavaScript - get weeks in a month as array of start and end days
//note: month is 0 based, just like Dates in js
function getWeeksInMonth(year, month) {
const weeks = [],
firstDate = new Date(year, month, 1),
lastDate = new Date(year, month + 1, 0),
numDays = lastDate.getDate();
let dayOfWeekCounter = firstDate.getDay();
for (let date = 1; date <= numDays; date++) {
@vigosan
vigosan / github-proxy-client.js
Created March 19, 2022 11:41 — forked from DavidWells/github-proxy-client.js
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
@vigosan
vigosan / mac-upgrade.sh
Created November 14, 2020 13:23 — forked from arturmartins/mac-upgrade.sh
How to keep your mac software updated easily (2019)
#!/bin/bash
# Requirements:
# - homebrew: https://brew.sh/
# - homebrew tap: buo/cask-upgrade - https://github.com/buo/homebrew-cask-upgrade
# - homebrew mas (Mac App Store command-line interface - https://github.com/mas-cli/mas)
# Update, upgrade all and cleanup
brew update && brew upgrade && brew cu --all --yes --cleanup && mas upgrade && brew cleanup
# Dump all taps, apps, casks and mac apps into ~/Brewfile
@vigosan
vigosan / remove-all-from-docker.sh
Created March 21, 2020 07:13 — forked from beeman/remove-all-from-docker.sh
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@vigosan
vigosan / SubscriptionHook.js
Created February 7, 2019 12:58 — forked from dabit3/SubscriptionHook.js
Example of using custom React hooks for managing GraphQL subscriptions
import { useEffect, useState } from 'react'
import { API, graphqlOperation } from 'aws-amplify'
const ListTalks = `
query {
listTalks {
items {
name
description
presenter {