Skip to content

Instantly share code, notes, and snippets.

View vmassuchetto's full-sized avatar

Vinicius Massuchetto vmassuchetto

View GitHub Profile
@vmassuchetto
vmassuchetto / migration.php
Last active August 29, 2015 13:55
WordPress migration template
<?php
// we need memory and time
ini set( 'memory limit', -1);
set_time_limit( 0 );
// WordPress environment
include( 'wp-load.php' );
@vmassuchetto
vmassuchetto / mcblist
Created August 24, 2014 20:44
Shell script to list MP3 files in the format "<title> (<minute:seconds lengh>)", as required by the MusicBrainz parser
#!/bin/bash
GREP="grep"
GREP_E="not found"
CURDIR=`pwd`
TITLEINFO_1="beet info "
TITLEINFO_2=" | grep \"\ title:\" | awk -F':' '{print \$2 }' | sed 's/^ //g'"
TIMEINFO_1="mp3info -p \"\%S\""
TIMEINFO_2=""
@vmassuchetto
vmassuchetto / copyallh.vba
Last active August 29, 2015 14:13
Copy all sheets of a Workbook to a 'Master' sheet horizontally
Sub CopyAllH()
Dim wrk As Workbook 'Workbook object
Dim sht As Worksheet 'Object for handling worksheets in loop
Dim trg As Worksheet 'Master Worksheet as a target
Dim col As Integer 'Column count
Dim i As Integer 'Some index
Dim rng As Range 'Range object
Dim rng1 As Range 'Range object
Dim rng2 As Range 'Range object
@vmassuchetto
vmassuchetto / sw-struct.py
Created April 11, 2015 14:35
SolidWorks BOM to database parent-child part number conversion
"""
Python script to generate SolidWorks BOM lists into a database-usable parent
child relationship.
CSV data of the first column:
"<parent>.<child>.<subchild>.<subsubchild>"
Usage:
@vmassuchetto
vmassuchetto / countbib
Created May 7, 2015 07:24
Shell script to count citations in TeX files
#!/bin/bash
#
# Counts the number of lines each citation appears on a tex file.
#
# Usage:
#
# ./countbib texfile.tex
#
TEXFILE=$1
@vmassuchetto
vmassuchetto / etc-init.d-protheus_env
Last active August 29, 2015 14:25
Variáveis de ambiente para o initscript do Totvs Microsiga Protheus: License server, cTree, DBAccess, Appserver e Workflow
#!/bin/bash
#
# Arquivo de ambiente para o Totvs Microsiga Protheus. Serve como suporte para
# um arquivo principal de execução disponível em:
# https://gist.github.com/vmassuchetto/d43886fa0726feb73b73
#
# Definição do ambiente
if [ -z "$PROTHEUS_ENV" ]; then
@vmassuchetto
vmassuchetto / router.php
Created February 13, 2013 12:23
GlotPress_Router
<?php
class GlotPress_Router {
/**
* Set rewrite rules
*
* @since 0.1
* @return New set of rewrite rules
*
@vmassuchetto
vmassuchetto / f2f.py
Created August 7, 2013 03:44
Import Flickr images from one account to another based on text files links.
#!/usr/bin/python
FILES_READ_PATH = '/path/to/txt/files'
FILES_WRITE_PATH = '/where/to/save/images'
FROM_USER = 'you_username'
FROM_FLICKR_API_KEY = 'some_key'
FROM_FLICKR_API_SECRET = 'some_secret'
TO_USER = 'your_username'
@vmassuchetto
vmassuchetto / oembed-youtube.sh
Last active December 21, 2015 06:09
Replace Youtube oEmbed entries by iframe tags in text files
#!/bin/bash
for FILE in `rgrep -il "youtube.com" * | grep -v iframe` ; do
perl -p -i -e 's/(<p>)?.*youtube\.com\/watch.*v=([A-Za-z0-9]*).*(<\/p>)?/<iframe width="560" height="315" frameborder="0" src="\/\/www\.youtube\.com\/embed\/\2\" allowfullscreen><\/iframe>/g' $FILE ;
done
@vmassuchetto
vmassuchetto / deploy.php
Last active December 28, 2015 00:19
PHP script to automate deploy using Git
<?php
/**
* This scripts is intended to be triggered by Git hooks. For deployment you'll
* probably want to use `post-update`:
* http://schacon.github.io/git/githooks.html#post-update
*
* First, set the `PASS` constant to limit access to this script and use it as
* a `pass` GET variable.
*