Skip to content

Instantly share code, notes, and snippets.

View raulb's full-sized avatar
👨‍💻
Ask me anything!

Raúl Barroso raulb

👨‍💻
Ask me anything!
View GitHub Profile
@raulb
raulb / gist:1091554
Created July 19, 2011 07:14 — forked from javierarce/gist:1090744
Color Picker bookmarklet for Dribbble.com
javascript: void((function() {
var colors = [];
var title = document.title.replace(/Dribbble - /g, '');
var li = document.getElementsByClassName('color');
if (li.length > 0) {
for (var i = 0; i < li.length; i++) {
var c = li[i].getElementsByTagName('a')[0].getAttribute('title');
colors.push('<li><div style="display:inline-block; width:20px; height:20px;background:' + c + '"></div> ' + c + '</li>');
}
@raulb
raulb / Dragabble table bookmarklet
Created August 1, 2011 11:26
Ability dragabble options to each cases in a table
window.bookmarklet = function(opts){fullFunc(opts)};
// These are the styles, scripts and callbacks we include in our bookmarklet:
window.bookmarklet({
js : ['http://dl.dropbox.com/u/3655882/jquery.tablednd_0_5.js'],
jqpath : 'http://jquery.com/src/jquery-latest.js',
ready : function(){
@raulb
raulb / gist:1867822
Created February 20, 2012 04:17
Fadeout test with Jasmine
// If we want to test Asynchronous events we should use waits or waitsFor
// To test a fadeOut effect, waits(num ms) could be ok, but is not too smart in my opinion
// more info: https://github.com/pivotal/jasmine/wiki/Asynchronous-specs
// What happens if we want to test if any element is correctly deleted but before of that the element is going into a fadeOut
// event?. Which is happening is its opacity is going to 0 but immediately of that the element is undefined.
// This is my way to do it:
it("If one element is deleted correctly", function() {
@raulb
raulb / gist:2030793
Created March 13, 2012 19:01
Generating font-face with SASS
$font-folder: "/fonts/"
// `font-face($name, $font-files, $eot, $weight, $style)
// ---------------------------------------------------------------
// Cross-browser support for @font-face. Supports IE, Gecko, Webkit, Opera.
// $name is required, arbitrary, and what you will use in font stacks.
// $font-files is required using font-files('relative/location', 'format'). for best results use this order: woff, opentype/truetype, svg
// $eot is required by IE, and is a relative location of the eot file.
@raulb
raulb / example-user.js
Created May 4, 2012 22:19 — forked from nijikokun/example-user.js
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9-_]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@raulb
raulb / gist:2727627
Created May 18, 2012 21:11
Cross browser select text
function selectText(element) {
var text = document.getElementById(element);
if ($.browser.msie) {
var range = document.body.createTextRange();
range.moveToElementText(text);
range.select();
} else if ($.browser.mozilla || $.browser.opera) {
@raulb
raulb / ios-media-queries.sass
Created June 12, 2012 22:24 — forked from faun/ios-media-queries.sass
iOS Media Queries for iPhone/iPod, iPad & Retina and Non-Retina Devices
.ipad-only,
.iphone-only,
.retina-only,
.non-retina-only,
.retina-iphone-only,
.non-retina-iphone-only
display: none
// iPad Only
@media only screen and (device-width: 768px)
@raulb
raulb / gist:2931487
Created June 14, 2012 16:59
Linear gradient and background image mixed with SASS
// Basic example
@mixin linear-gradient-image($image-url, $start-color, $stop-color)
background: url(#{$image-url}) right 0 no-repeat, $stop-color
background: url(#{$image-url}) right 0 no-repeat, -moz-linear-gradient(top, $start-color, $stop-color)
background: url(#{$image-url}) right 0 no-repeat, -ms-linear-gradient(top, $start-color, $stop-color)
background: url(#{$image-url}) right 0 no-repeat, -o-linear-gradient(top, $start-color, $stop-color)
background: url(#{$image-url}) right 0 no-repeat, -webkit-gradient(linear, left top, left bottom, from($start-color), to($stop-color))
background: url(#{$image-url}) right 0 no-repeat, -webkit-linear-gradient(top, $start-color, $stop-color)
background: url(#{$image-url}) right 0 no-repeat, linear-gradient(top, $start-color, $stop-color)
@raulb
raulb / gist:3101058
Created July 12, 2012 21:18
Retrieving source code using XMLhttpRequest with JS
  var req = new XMLHttpRequest();
  req.open(
      "GET",
      "URL",
      true);
  req.onreadystatechange = statusListener;
  req.send(null);

 function statusListener()
@raulb
raulb / gist:5251844
Last active August 21, 2018 14:51
English is hard

ENGLISH IS FOGGING HARD

Let's face it. I'm not the Queen Elizabeth in what concerns to speak English. But ey! (hey!), just help me. I know you wanted to tell me: "Idiot, it's not like that", now you have your chance. Add your comments/pr/merges/forkes/... here and contribute to the cause of why I am paying a psychologist every month (also, can you recommend me someone?)

I wrote (it is)

  • It should works (It should work)
  • Looks fine for you (Looks fine to you)
  • Dial you (Dial you in)
  • Oyster egss (Easter eggs)