Skip to content

Instantly share code, notes, and snippets.

View ivamluz's full-sized avatar

Ivam Luz ivamluz

  • Appnovation
  • Campinas
View GitHub Profile
@ivamluz
ivamluz / twitter4j-find-replies.java
Last active June 6, 2023 16:22
Code snippet showing how to post a reply to a tweet using twitter4j library
public static List<Status> findReplies() {
Query query = new Query("iluzcit");
List<Status> tweets = new ArrayList<Status>();
Twitter twitter = new TwitterFactory().getInstance();
try {
QueryResult result;
do {
result = twitter.search(query);
# contents of ~/.gitconfig file
[user]
name = my user name
email = my email
[http]
sslVerify = false
[alias]
tree = log --graph --decorate --pretty=oneline --abbrev-commit
@ivamluz
ivamluz / PhoneNumberFormat.java
Last active August 29, 2015 14:03
Sample Java code formatting a Brazilian phone number using regex along with String.replaceAll()
class PhoneNumberFormat {
public static void main (String[] args) {
System.out.println("21436587".replaceAll("^([0-9]{4,5})[^0-9]*([0-9]{4})$", "$1-$2")); // outputs "2143-6587"
System.out.println("2143-6587".replaceAll("^([0-9]{4,5})[^0-9]*([0-9]{4})$", "$1-$2")); // outputs "2143-6587"
System.out.println("921436587".replaceAll("^([0-9]{4,5})[^0-9]*([0-9]{4})$", "$1-$2")); // outputs "92143-6587"
System.out.println("92143-6587".replaceAll("^([0-9]{4,5})[^0-9]*([0-9]{4})$", "$1-$2")); // outputs "92143-6587"
}
}
@ivamluz
ivamluz / DrupalParseInfoFile.php
Last active August 29, 2015 14:03
Regex (and PHP code sample) for parsing Drupal .info files
<?php
if (preg_match('/^([a-zA-Z\[\]]+)\s*=\s*(.+)$/', $line, $matches)) {
// $matches[0]: whole line matched
// $matches[1]: property name
// $matches[2]: property value
}
@ivamluz
ivamluz / git-pull-all.sh
Last active August 29, 2015 14:07
Shell script for updating all git repositories under the current directory
#/bin/bash
BASE_DIR=`pwd`
for D in $(find . -mindepth 1 -maxdepth 1 -type d) ; do
cd $BASE_DIR/$D;
echo "Updating git repository at $D"
git pull
done
@ivamluz
ivamluz / pysyntaxcheck.sh
Created October 23, 2014 17:45
Alias for checking syntax of Python files
alias pysyntaxcheck="python -m py_compile"
# Usage: pysyntaxcheck /path/to/file
@ivamluz
ivamluz / cleanup-bulkloader-logs.sh
Created December 31, 2014 11:01
Recursively removes all Google AppEngine bulkloader ouput files inside a folder
#!/usr/bin/env bash
FOLDER=$1
if [ -z "$FOLDER" ]; then
echo "Usage: cleanup-bulkloader-logs.sh </path/to/dir>"
exit 1
fi
echo "Recursively cleaning up bulkloader-log* files under ${FOLDER}"
# 1/0.25 reduces video velocity by 4. 1/2 would double the velocity.
avconv -i <video-in> -vf "setpts=(1/0.25)*PTS" <video-out>
avconv -i <video-in> -acodec mp2 <video-out>
alias adb-kill-monkey=$'adb shell ps | awk \'/com\.android\.commands\.monkey/ { system("adb shell kill " $2) }\''