Skip to content

Instantly share code, notes, and snippets.

View raultm's full-sized avatar

Raul Tierno raultm

View GitHub Profile
@raultm
raultm / jquery.loadContent.js
Created May 9, 2012 08:39
Little jQuery plugin to prevent new load or abort previous one
(function($, window, undefined){
var requests = {}
$.fn.loadContent = function(url, opts){
/*
*
* Customization
*
@raultm
raultm / StretchVideoView.java
Created September 16, 2012 17:03
Android : How to stretch video to use whole area of VideoView (sode snippets)
package com.raulete.dev.stretchvideoview.utils;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.VideoView;
public class StretchVideoView extends VideoView {
public StretchVideoView(Context context) {
super(context);
}
@raultm
raultm / openActivity.java
Created November 18, 2012 22:36
Android : Beginner Tips & Snippets
// Call from a Context(e.g. an Activity)
public void openTargetActivity(){
startActivity(new Intent(this, TargetActivity.class))
}
@raultm
raultm / siaf.js
Created November 30, 2012 17:49
Self-Invoked Anonymous Function
(function(msg){
console.log(msg);
})("42");
@raultm
raultm / gist:5041668
Created February 26, 2013 20:05
Código de ejemplo para marcar la última palabra de una cadena con un color de text y de fondo concretos
// Método para cambiar estilos a la última palabra
private Spannable highlightLastWordOfSentence(String sentence, int backgroundColor, int foregroundColor){
int startIndexOfLastWord = sentence.lastIndexOf(" ") + 1;
int endIndexOfLastWord = sentence.length();
SpannableStringBuilder spannable = new SpannableStringBuilder(sentence);
BackgroundColorSpan backgroundSpan = new BackgroundColorSpan(backgroundColor);
spannable.setSpan(backgroundSpan, startIndexOfLastWord, endIndexOfLastWord, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
ForegroundColorSpan foregroundSpan = new ForegroundColorSpan(foregroundColor);
@raultm
raultm / ExampleTestData.php
Last active December 19, 2015 21:39
CakeTestSuite with setup to load sql file in test configuration before start Reference: http://stackoverflow.com/questions/8496921/how-to-prevent-fixtures-from-being-reloaded-between-tests-with-cakephp-and-phpun
<?php
require_once(CORE_PATH . 'Cake/Model/ConnectionManager.php');
class ExampleTestData extends CakeTestSuite {
public static function suite() {
self::loadDB();
$suite = new CakeTestSuite('Name Of The Suite');
$suite->addTestDirectory(TESTS . 'Case' . DS . 'Sample');
return $suite;
public class Calculator {
public static String[][] values = {
{ "CM", "DCD" },
{ "M", "DD" },
{ "CD", "CCCC" },
{ "D", "CCCCC" },
{ "XC", "LXL" },
@raultm
raultm / commands.sh
Created November 11, 2013 23:05
Commands to convert Mavericks installer in Mavericks ISO Source : http://thezinx.com/2013/10/29/create-bootable-dmg-iso-mavericks-app.html
# Source : http://thezinx.com/2013/10/29/create-bootable-dmg-iso-mavericks-app.html
# Mount the installer image
hdiutil attach /Applications/Install\ OS\ X\ Mavericks.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
# Convert the boot image to a sparse bundle
hdiutil convert /Volumes/install_app/BaseSystem.dmg -format UDSP -o /tmp/Mavericks
# Increase the sparse bundle capacity to accommodate the packages
hdiutil resize -size 8g /tmp/Mavericks.sparseimage
// No DI
public class Car{
private Motor motor;
public Car(){
motor = new ElectricMotor();
}
}
@raultm
raultm / containable example
Last active August 29, 2015 13:59
Containable Example Cakephp
<?php
$this->University->Behaviors->load('Containable');
$containArray = array(
'Course' => array(
'Group' => array(
'Studen' => array(
'Marks'
)
)
)