Skip to content

Instantly share code, notes, and snippets.

@fguillen
fguillen / nice_file_field.js
Last active February 22, 2019 18:33
Pretty 'input[type="file"]' for Bootstrap addicts
// Based in: http://duckranger.com/2012/06/pretty-file-input-field-in-bootstrap/
// Version: 0.0.3
// Compatibility with: Bootstrap 3.2.0 and jQuery 2.1.1
// Use:
// <input class="nice_file_field" type="file" data-label="Choose Document">
// <script> $(".nice_file_field").niceFileField(); </script>
//
(function( $ ) {
$.fn.niceFileField = function() {
this.each(function(index, file_field) {
<html>
<video width="340" controls="controls" id="video">
<source src="http://archive.org/download/Pepa-creativeCommonsMp4956/Pepa-creativeCommonsMp4956.mp4" type="video/mp4" />
<track kind="subtitles" src="https://gist.github.com/fguillen/4742221/raw/83d2e2d1f2e0bdc96a733a15b608941216ab9fca/subs.+vtt"/>
</video>
</html>
@fguillen
fguillen / .gitignore
Last active December 12, 2015 06:49
Code example to reproduce the issue "ActiveRecord, find by polymorphic attribute" http://stackoverflow.com/q/14753611/316700
.rvmrc
polymorphic.sqlite
@fguillen
fguillen / array_shuffle_into.rb
Created February 6, 2013 11:06
Ruby, how to shuffle one array into another
# Inspired in the answers: http://stackoverflow.com/questions/4908413/how-to-initialize-an-array-in-one-step-using-ruby
class Array
def shuffle_into(array)
a1 = self.dup
a2 = array.dup
(a1.size + a2.size).times.map do
[true, false].sample ? (a1.shift || a2.shift) : (a2.shift || a1.shift)
end
@fguillen
fguillen / AutoUpdatedCollection.js
Created August 7, 2012 18:58
Backbone AutoUpdatedCollection
/*
In the scenario you have a _shared Collection_ which contains every Model of one class,
and this Collection is used to populate _sub-Collections_ those have to be _updated_
when the shared Collection is updated.
*/
App.AutoUpdatedCollection = Backbone.Model.extend({
initialize: function( opts ){
this.name = opts.name;
this.sourceCollection = opts.sourceCollection;
@fguillen
fguillen / ajax_events.js
Created July 26, 2012 15:44
Declaring console log for every AJAX Event
$(function(){
console.log( "Loading AJAX Event logger ..." );
$(document).ajaxSend( function( event, jqXHR, ajaxOptions ){
console.log( "ajaxSend" );
console.log( "ajaxSend.event", event );
console.log( "ajaxSend.jqXHR", jqXHR );
console.log( "ajaxSend.ajaxOptions", ajaxOptions );
});
@fguillen
fguillen / testa-README.md
Created March 13, 2012 10:57
explanation of new TESTA functionalities

I have been reading the shared documentation:

It is a good work what you have done here but it looks like a little confuse due the 90% of the doc is talking about technical stuff.

This technical information is gonna be helpful for the development but in a "specification" time we should focus in "what we need" and not in "how to implement it"..

Also Juan has pointed me that we can not use the name BrowserShooter because is misunderstanding its possibilities. BrowserShooter is not a VM screenshot system but a Multi-Browser test system, with a lot of configuration possibilites we are still requesting as missing. For now on we can use the key name "TESTA" for this project.. or any other thing you suggest :)

@fguillen
fguillen / suite-description.yml
Created March 13, 2012 10:18
TESTA suite description
output_path: "~/testa-logs"
tests:
interstitial:
name: "interstitial"
commands: |
navigate.to "http://interstitial.com"
command1
command2
@fguillen
fguillen / middle_point_coordinates.js
Created March 3, 2012 12:22
Calculation of the coordinates or a point in the middle of two points
function distancePoints( xA, yA, xB, yB ){
var xDistance = Math.abs( xA - xB );
var yDistance = Math.abs( yA - yB );
return Math.sqrt( Math.pow( xDistance, 2 ) + Math.pow( yDistance, 2 ) );
}
function coordinatesMediumPoint( xA, yA, xB, yB, distanceAC ){
var distanceAB = distancePoints( xA, yA, xB, yB );
var angleAB = Math.atan2( ( yB - yA ), ( xB - xA ) );
@fguillen
fguillen / EvasiveMouse.md
Created February 27, 2012 17:15
Coding Puzzle example

EvasiveMouse

An smart mouse always obtains the cheese without being detected.

Description

You are an office mouse, and you're very lucky because in every office of the building where you live there is always one piece of cheese.

You have worked hard to make one mousehole in every office.