Skip to content

Instantly share code, notes, and snippets.

View MarioRicalde's full-sized avatar

Mario Ricalde MarioRicalde

View GitHub Profile
@MarioRicalde
MarioRicalde / youtube-url-regexp.php
Last active February 18, 2021 06:32
YouTube URL PHP Regexp Shit
<?php
/**
* YouTube Preg Match Test Case.
*
* @author Mario "Kuroir" Ricalde
*/
// Regular Expression (the magic).
$youtube_regexp = "/^http:\/\/(?:www\.)?(?:youtube.com|youtu.be)\/(?:watch\?(?=.*v=([\w\-]+))(?:\S+)?|([\w\-]+))$/";
@MarioRicalde
MarioRicalde / Pagination101.md
Created May 27, 2012 08:00 — forked from mislav/pagination.md
"Pagination 101" by Faruk Ateş

Pagination 101

Article by Faruk Ateş, [originally on KuraFire.net][original] which is currently down

One of the most commonly overlooked and under-refined elements of a website is its pagination controls. In many cases, these are treated as an afterthought. I rarely come across a website that has decent pagination, and it always makes me wonder why so few manage to get it right. After all, I'd say that pagination is pretty easy to get right. Alas, that doesn't seem the case, so after encouragement from Chris Messina on Flickr I decided to write my Pagination 101, hopefully it'll give you some clues as to what makes good pagination.

Before going into analyzing good and bad pagination, I want to explain just what I consider to be pagination: Pagination is any kind of control system that lets the user browse through pages of search results, archives, or any other kind of continued content. Search results are the o

@MarioRicalde
MarioRicalde / git-recover-branch.md
Created October 29, 2012 01:30 — forked from jbgo/git-recover-branch.md
How to recover a git branch you accidentally deleted

Oops! I accidentally deleted a local git branch, and I haven't pushed it to a remote server yet. The branch has several important commits, and it hasn't been merged with any other branches yet. How do I find the missing branch?

1. Create a list of all dangling or unreachable commits.

$ git fsck --full --no-reflogs --unreachable --lost-found
unreachable tree 4a407b1b09e0d8a16be70aa1547332432a698e18
unreachable tree 5040d8cf08c78119e66b9a3f8c4b61a240229259
unreachable tree 60c0ce61b040f5e604850f747f525e88043dae12
unreachable tree f080522d06b9853a2f18eeeb898724da4af7aed9
@MarioRicalde
MarioRicalde / install-all-sky-fonts.js
Last active January 3, 2016 04:58
Installing all SkyFonts - run this on your JavaScript console.
var time = 500;
$('.skyfonts-wrapper').each(function() {
var el = this;
time += 500;
setTimeout( function() {
$(el).find('button').click().parent().parent().find('.skyfonts-dropdown .input-submit').click();
console.log('installing...');
}, time );
})
@MarioRicalde
MarioRicalde / sshcd.sh
Last active August 29, 2015 13:56
SSH Change to Directory
# SSH Change Directory
function sshcd() {
port=""
getopts ":p:" opt;
if [ ! -z $OPTARG ]; then
port="-p $OPTARG"
shift 2
fi

Mac Color Picking Done Right

Picking a Color on Mac is hard. Mainly due to the fact that several applications floating around the web ( AppStore and independant ), grab the color "incorrectly".

Why incorrectly?

The color picker is not picking the "real" color, but rather, it's picking the color that your screen is displaying, what do I mean?

Lets try to grab the following color:

@MarioRicalde
MarioRicalde / imgdim.sh
Last active August 29, 2015 13:56
Copy the image dimensions as CSS via Terminal.
function imgdim() {
echo "Image Dimensions copied to the Clipboard."
sips -g pixelHeight -g pixelWidth $1 | sed '1 d' | sed 's/ pixelHeight: \(.*\)/height: \1px;/' | sed 's/ pixelWidth: \(.*\)/width: \1px;/' | pbcopy
}
@MarioRicalde
MarioRicalde / tmux-cheatsheet.markdown
Created July 25, 2014 07:56 — forked from MohamedAlaa/tmux-cheatsheet.markdown
A comprensive cheat-sheet for everything Tmux.

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@MarioRicalde
MarioRicalde / javascript_resources.md
Created July 25, 2014 07:57 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage