Skip to content

Instantly share code, notes, and snippets.

View Mazuh's full-sized avatar
👨‍💻
Code Summoner

Marcell Guilherme Costa da Silva Mazuh

👨‍💻
Code Summoner
View GitHub Profile
@Mazuh
Mazuh / src.sh
Created March 11, 2018 18:35
Quck xsetwacom setup
xsetwacom list
pen="Wacom Intuos S 2 Pen stylus"
pad="Wacom Intuos S 2 Pad pad"
xsetwacom set "$pad" Button 3 'key ctrl z' # undo
xsetwacom set "$pen" Button 2 'key p' # paint brush
xsetwacom set "$pen" Button 3 'key shift e' # erase tool
@Mazuh
Mazuh / desc_kw.py
Last active April 9, 2018 15:57
Python keywords sorted descendingly by their length, as JSON-like
import keyword
', '.join(['"%s"' % kw for kw in sorted(keyword.kwlist, key=len, reverse=True)])
@Mazuh
Mazuh / App.js
Last active June 17, 2018 19:47
Dumb sample of SimpleWebRTC lib.
import React from 'react';
import SimpleWebRTC from 'simplewebrtc';
import './App.css';
export default class App extends React.Component {
componentDidMount() {
const webrtc = new SimpleWebRTC({
autoRequestMedia: true,
localVideoEl: 'local-video',
remoteVideosEl: 'remote-videos-container',
@Mazuh
Mazuh / blame_stats.sh
Created November 21, 2018 22:31
Script for reading stats for the git blames of Verto code over the years.
echo "Analyzing..."
for filename in ./*.js; do
total=`git blame $filename | wc -l`
echo "$filename"
for year in 2014 2015 2016 2017 2018; do
yearly=`git blame $filename | grep ".*$year-\d\d-\d\d.*" | wc -l`
percent=`expr 100 \* $yearly / $total`
tonys_yearly=`git blame $filename | grep ".*Anthony Minessale.*$year-\d\d-\d\d.*" | wc -l`
tonys_percent=`expr 100 \* $tonys_yearly / $total`
echo " $year: $yearly (yearly $percent% by everyone and $tonys_percent% by Anthony)"
@Mazuh
Mazuh / sdp-handler.js
Last active March 21, 2019 14:20
Functional and pure helper to assure video comes first on SDP media lines (tho not so pragmatic). Forked from: https://gist.github.com/edolix/73b2e085104250691a421b8f3678c86c
export function reorderSdpMediaLines(sdp) {
const lineBreaker = '\r\n';
const parsed = sdp.split(lineBreaker).reduce((parser, line) => {
const reading = (line.startsWith('m=video') && 'video')
|| (line.startsWith('m=audio') && 'audio')
|| parser.reading;
if (line === '') {
return parser;
}
@Mazuh
Mazuh / clean_branchs.sh
Created March 21, 2019 14:22
Cleaning all git branches, except the master, in the current repository directory.
git branch | grep -v "master" | xargs git branch -D
@Mazuh
Mazuh / clean_pyc_files.sh
Created April 24, 2019 19:05
Clean .pyc files from current subdirectories
find . -name '*.pyc' -delete
@Mazuh
Mazuh / applyToQueuedPromises.js
Last active November 29, 2019 13:26
Queued Promises maker
import chunk from 'lodash/chunk';
/**
*
* Util to map values to `Promise`s and invoke them in queue order,
* being assured each `Promise` is resolved before the next be created.
*
* It reduces `data` array to a `Promise` which is the accumulated chain
* of async tasks resulting of each element mapped thru `asyncIteratee`.
* As a chain, each `asyncIteratee` follows a queue order of call, and
@Mazuh
Mazuh / tasks-crud-local-storage.js
Created March 7, 2020 13:07
CRUD for tasks on local storage.
import { v4 as uuidv4 } from 'uuid';
const TASKS_KEY = 'tasks';
export const retrieveTasks = () => {
const serialized = localStorage.getItem(TASKS_KEY);
const tasks = serialized ? JSON.parse(serialized) : [];
return tasks;
};
@Mazuh
Mazuh / rm-docker-dangling-volumes.sh
Created April 16, 2020 05:00
Remove all Docker dangling volumes
docker volume rm `docker volume ls -q -f dangling=true`