Skip to content

Instantly share code, notes, and snippets.

View dafi's full-sized avatar

Davide Ficano dafi

View GitHub Profile
@dafi
dafi / gotocircle.gm
Created September 7, 2012 14:19
Go to circle (GreaseMonkey script)
// ==UserScript==
// @name GPlus go to circle
// @namespace http://dafigplus/
// @version 0.1
// @description Change links on google and google plus to go on specific circle
// @match http://*google*
// @match https://*google*
// @copyright 2012+, You
// ==/UserScript==
var defaultCircleUrl = 'https://plus.google.com/u/0/stream/circles/p21da507289aa9fa1';
@dafi
dafi / OSXFrameworksList.md
Created January 21, 2013 08:37
List of frameworks, library or other reusable code for OSX
@dafi
dafi / permutation.js
Created April 22, 2013 04:44
All permutations for a given string
// From http://stackoverflow.com/questions/9960908/permutations-in-javascript
var permArr = [],
usedChars = [];
function permute(input) {
var i, ch;
for (i = 0; i < input.length; i++) {
ch = input.splice(i, 1)[0];
usedChars.push(ch);
@dafi
dafi / gource2mp4.sh
Created May 25, 2013 08:41
Gource best configuration for a big repository The configuration shown here generates a good video to upload on youtube
gource -1920x1080 --title "MyTitle" --hide filenames --stop-at-end --file-idle-time 0 -o temporary.ppm --seconds-per-day .00050 ~/prj/svn/myproject
ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i temporary.ppm -vcodec libx264 -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 -preset slow finalVideo.mp4
@dafi
dafi / incVersionCode.js
Last active December 27, 2015 03:58
node.js script to increment the AndroidManifest.xml versionCode value
var fs = require('fs');
var androidManifest = fs.readFileSync("AndroidManifest.xml", 'utf-8');
var m = androidManifest.match(/android:versionCode="([0-9]+)"/);
if (m) {
var versionCode = parseInt(m[1], 10) + 1;
var updatedAndroidManifest = androidManifest.replace(/(android:versionCode=")([0-9]+)(")/, '$1' + versionCode + '$3');
fs.writeFileSync("AndroidManifest.xml", updatedAndroidManifest, 'utf-8');
console.log('Updated versionCode to ' + versionCode);
@dafi
dafi / vagrant.sh
Last active February 27, 2018 17:00
Installing vagrant on Centos 6
# Install virtualbox
cd /etc/yum.repos.d/
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
sudo yum update
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
sudo yum -y install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms
sudo yum -y install VirtualBox-4.2
@dafi
dafi / getRealPathFromImageURI.java
Last active December 28, 2015 16:09
android - Working with MediaStore to share image from buffer and obtain the uri real path
public static String getRealPathFromImageURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = { MediaStore.Images.Media.DATA };
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} finally {
if (cursor != null) {
@dafi
dafi / 0_reuse_code.js
Created November 18, 2013 13:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dafi
dafi / updateSingleRow.java
Created November 22, 2013 08:37
Get a specific item from listView adapter
public void updateSingleRow(int position)
{
if (position >= listView.getFirstVisiblePosition() && position < listView.getLastVisiblePosition())
{
View v = ((ViewGroup) listView.getChildAt(listView.getHeaderViewsCount() + (position - listView.getFirstVisiblePosition())))
.getChildAt(0);
adapter.getView(position, v, listView);
}
}
@dafi
dafi / ClickableTextView.java
Created November 26, 2013 12:49
Android TextView changing color when clicked. It uses the setSelect(); to change color. Show how to change text color and background
package com.ternaryop.phototumblrshare.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.TextView;
public class ClickableTextView extends TextView implements OnTouchListener {