Skip to content

Instantly share code, notes, and snippets.

@valtoni
valtoni / patch.cmd
Created July 9, 2012 19:15
[DOS] Patchin any directory
@echo off
set ACTUAL_DIR=%CD%
set TEMPFILE=%TEMP%\temp.patch
echo "Executando diff"
diff -uNr --exclude=".svn" %1 %2 > %TEMPFILE%
echo "Patcheando destino"
cd %2
patch -R -i %TEMPFILE%
@valtoni
valtoni / makeffmpeg.sh
Last active October 10, 2015 20:38
Script to install new ffmpeg in MACOSX (Mountain Lion)
#!/bin/bash
WORK_DIR=~/temp_ffmpeg
LAME_DIR=$WORK_DIR/lame
FAAC_DIR=$WORK_DIR/faac-1.28
FAAD2_DIR=$WORK_DIR/faad2-2.7
AUTOCONF_DIR=$WORK_DIR/autoconf-2.69
AUTOMAKE_DIR=$WORK_DIR/automake-1.12.4
YASM_DIR=$WORK_DIR/yasm
FFMPEG_DIR=$WORK_DIR/ffmpeg
@valtoni
valtoni / diff-dir.sh
Created October 10, 2012 14:04
[unix] Patching directory: origin to target (exclude .svn dirs)
#!/bin/sh
# IMPORTANT: SOURCE and TARGET are relative to ACTUAL_DIR. Whathever, the patch won't work.
ACTUAL_DIR=$(pwd)
PATCH_FILE="$ACTUAL_DIR/diff.patch"
PATCH_FILE_TMP="$PATCH_FILE.tmp"
SOURCE=$1
TARGET=$2
# import the main window object (mw) from ankiqt
from aqt import mw
# import the "show info" tool from utils.py
from aqt.utils import showInfo
# import all of the Qt GUI library
from aqt.qt import *
from time import mktime,time
from datetime import datetime
@valtoni
valtoni / EarClasloaderFinder.java
Created April 2, 2014 18:21
This chunck show classloaders and responsibles for your charge.
private static void printClassInfo(String className) {
Class<?> loadedClass;
try {
loadedClass = Class.forName(className);
System.out.println("Actual classloader: " + Thread.currentThread().getContextClassLoader());
System.out.println("+ Class " + className + " loaded <<<<");
if (loadedClass.getClassLoader() == null) {
System.out.println(" +- NO CLASSLOADER FOUND FOR CLASS " + loadedClass);
}
else {
public class Ipc2014ProblemA {
private static class BaggageBin {
int space;
char destination;
public BaggageBin(int space) {
if (space > 0) {
if (space % 2 == 0) {
this.destination = 'A';
@valtoni
valtoni / config-ddwrt-rw.sh
Last active June 29, 2017 17:39 — forked from Thinkscape/gist:3426581
Config Read Write mode in DD WRT Router
# From: http://www.dd-wrt.com/phpBB2/viewtopic.php?t=86912
# 1. Prepare the USB disk
# Create an ext3 partition using GParted for instance
#2. Configure DD-WRT
#Under Services->Services->Secure Shell:
#* Enable SSHd
#* Click Apply Settings
#
@valtoni
valtoni / MemoryPropertyBuilder.java
Created April 14, 2015 12:44
Create an property file in memory (Builder like)
static class MemoryPropertyBuilder {
StringBuilder builder = new StringBuilder();
PropertyBuilder add(String param, String value) {
builder.append(param + "=" + value);
return this;
}
Properties properties() {
public class Testa {
private static int fatorial(int numero) {
if (numero == 1)
return 1;
return numero * fatorial(--numero);
}
private static int combinacao(int n, int p) {
return fatorial(n) / (fatorial(n - p) * fatorial(p));
}
@valtoni
valtoni / GMapV2Direction.java
Last active April 8, 2016 12:23
How to obtain directions from code to destiny, using google maps api.
import java.io.InputStream;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;