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 / infobus_data.json
Last active March 7, 2021 00:34
Digital version of UFRN's bus departure times and some other metadata for InfoBus clients. Check InfoBus-UFRN repository for more details: <https://github.com/Mazuh/InfoBusUFRN-App>.
{
"meta": {
"supportedMobileVersions": [
"2.0.0", "2.2.0"
]
},
"content": {
"mobileMessage": {
"title": "Fique seguro(a)!",
"isAnEmergency": true,
@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 / .gitlab-ci.yml
Last active May 13, 2022 04:53
Example of gitlab CI/CD for a create-react-app application on Amazon S3 Bucket.
image: nikolaik/python-nodejs:latest
stages:
- install
- test
- deploy
prodInstall:
stage: install
script:
@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 / compact-object.js
Last active September 22, 2022 07:21
Remove all empty objects and undefined values from a nested object -- an enhanced and vanilla version of Lodash's `compact`.
function compactObject(data) {
if (typeof data !== 'object') {
return data;
}
return Object.keys(data).reduce(function(accumulator, key) {
const isObject = typeof data[key] === 'object';
const value = isObject ? compactObject(data[key]) : data[key];
const isEmptyObject = isObject && !Object.keys(value).length;
if (value === undefined || isEmptyObject) {
@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