Skip to content

Instantly share code, notes, and snippets.

View marciopuga's full-sized avatar

Marcio Puga marciopuga

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vanilla Boilerplate / threejs + gsap</title>
<style>
html,
body {
@marciopuga
marciopuga / killport.md
Created October 26, 2021 10:50
Kill service/server running on a port

Kill any server running on port 8080

lsof -i TCP:8080 | awk 'NR > 1 {print $2}' | xargs kill -9

or add to bash

function killport() {
  echo "Killing processes on port $1"
  lsof -i TCP:$1 | awk 'NR > 1 {print $2}'  | xargs kill -9
}
@marciopuga
marciopuga / gif.sh
Last active January 13, 2022 11:37
video to gif using ffmpeg with superior quality
#!/bin/sh
# run docker version instead of local installation
alias ffmpeg='docker run -v=`pwd`:/tmp/ffmpeg opencoconut/ffmpeg'
palette="palette.png"
# adjust fps here if you need to
filters="fps=10,scale=$1:-1:flags=lanczos"
@marciopuga
marciopuga / test.sh
Last active July 15, 2019 00:36
Test if Tensorflow inside a docker container can see nvidia-driver installed in the host
docker run --runtime=nvidia -it --rm tensorflow/tensorflow:latest-gpu-py3 nvidia-smi
@marciopuga
marciopuga / index.js
Created March 26, 2019 04:45
Send POST request using Vanilla Node.js
const http = require('http')
const options = {
hostname: 'localhost',
port: 3000,
path: '/path',
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
}
@marciopuga
marciopuga / gist:e0c36878d76eb9a6f90caae030a0547d
Created January 30, 2019 01:49
Update package.json with all newer packages
Using npm-check-updates
https://github.com/tjunnone/npm-check-updates
`npm install -g npm-check-updates`
`ncu -u`
@marciopuga
marciopuga / gist:d27b85de52f78f86c368c96f292a1008
Created October 11, 2018 05:02
Remove all docker dangling images
docker rmi $(docker images --quiet --filter "dangling=true")
@marciopuga
marciopuga / docker-compose.yml for development
Last active May 8, 2017 01:49
Microservices running on Docker reverse proxy using Traefik, Docker Swarm and Docker Compose v3
version: '3'
services:
traefik:
image: marciopuga/traefik:latest
build: ./traefik/.
command: --web --docker --docker.domain=docker.localhost --docker.watch \
--logLevel=DEBUG \
--docker.exposedbydefault=false \
--entryPoints='Name:http Address::80' \
--defaultEntryPoints='http'
@marciopuga
marciopuga / factory-shared.es5.js
Created November 8, 2016 20:39 — forked from PatrickJS/factory-shared.es5.js
Different examples of OOP "class" with "inheritance" done using JavaScript including languages that transpile into js. Take notice to the amount of boilerplate that's needed in ES5 compared to ES6. These examples all have the same interface with pros/cons for each pattern. If they seem similar that's whole point especially the difference between…
var EventEmitter = require('events').EventEmitter;
var _ = require('lodash');
// Factory shared
var makePerson = function() {
var person = {};
EventEmitter.call(person);
person.wallet = 0;
_.extend(person, personMethods)
return person;
@marciopuga
marciopuga / vimdiff.md
Created October 12, 2016 20:55 — forked from mattratleph/vimdiff.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)