Skip to content

Instantly share code, notes, and snippets.

View mcarneiro's full-sized avatar

Marcelo Miranda Carneiro mcarneiro

View GitHub Profile
@mcarneiro
mcarneiro / app.js
Last active May 3, 2021 14:45
nodejs simple static vanilla server (for dev/homolog reasons)
const http = require('http')
const fs = require('fs')
const port = process.env.PORT || process.env.npm_config_port || process.env.npm_package_config_port || 3000
const typeList = {
html: 'text/html',
svg: 'image/svg+xml',
json: 'application/json',
js: 'application/javascript',
css: 'text/css',
@mcarneiro
mcarneiro / ffmpeg-utils
Last active December 28, 2020 15:39
ffmpeg
# cut video with 15s from 0s (super fast without conversion)
ffmpeg -ss 00:00:00 -t 00:00:15 -i [input] -c copy [output]
# fixed audio quality with 20% volume https://trac.ffmpeg.org/wiki/Encode/MP3
ffmpeg -i input.mp3 -map 0:a:0 -filter:a "volume=0.2" -b:a 80k output.mp3
# variable audio quality
ffmpeg -i input.mp3 -map 0:a:0 -qscale:a 7 output.mp3
@mcarneiro
mcarneiro / facebook.html
Created June 1, 2017 12:57
Facebook login + getting image from feed.
<!doctype html>
<html>
<head>
<title>Test facebook feed</title>
<script>
window.getFeed = function() {
FB.api('/me/feed', function(response) {
console.log('me', response);
if (response.data[0]) {
@mcarneiro
mcarneiro / setup.sh
Last active June 10, 2021 18:00
Programs I need to install when I get a new computer
#!/bin/bash
set -e
APT_INSTALL=()
[ "$(which git)" == "" ] && APT_INSTALL+=("git")
[ "$(which curl)" == "" ] && APT_INSTALL+=("curl")
[ "$(which vim)" == "" ] && APT_INSTALL+=("vim")
[ "$(which gpick)" == "" ] && APT_INSTALL+=("gpick")
@mcarneiro
mcarneiro / SassMeister-input.scss
Created February 5, 2015 17:11
Generated by SassMeister.com.
// ----
// libsass (v3.1.0-beta)
// ----
.test-zero {
$var1: 0px;
$var2: 0;
content: "values should be false";
_1: ($var1 * $var2) > 0;
_2: ($var1 * $var2) / 1px > 0; // converting to unitless works
@mcarneiro
mcarneiro / msql-basic-commands.sh
Last active October 4, 2015 05:08
Util MySQL commands
##################
## command line ##
##################
# run mysql;
mysql -h[host] -u[user] [database]
# dump database;
mysqldump -uroot [database] > database.sql
@mcarneiro
mcarneiro / getSymbolPositions.js
Last active December 28, 2020 15:34
JS util stuff
function getSymbolPositions(text, value){
var positions = text.split(value),
results = [];
for(var i=0, len = positions.length-1; i<len; i++){
results.push(positions[i].length + (results[i-1] + 1 || 0));
}
return results;
}
getSymbolPositions("1234561891abcdefghi1lmnop", "1"); // [0, 6, 9, 19]
@mcarneiro
mcarneiro / log-by-user
Created September 15, 2010 16:03
bash commands for SVN
#!/bin/bash
if [ "$1" = "?" ]
then
B1="\033[1m";
B2="\033[0m";
echo -e "";
echo -e "${B1}AUTHOR${B2}";
echo -e " Marcelo Miranda Carneiro - mcarneiro@gmail.com";
echo -e "";
@mcarneiro
mcarneiro / replace.xsl
Created August 30, 2010 22:36
useful functions for xslt 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" encoding="utf-8" indent="yes" omit-xml-declaration="yes" />
<!-- usage
<xsl:variable name="value">
<xsl:call-template name="replace">
<xsl:with-param name="value" select="{root}teste/index.html" />
<xsl:with-param name="from" select="'{root}'" />
<xsl:with-param name="to" select="http://www.carneiro.com/" />
</xsl:call-template>