Skip to content

Instantly share code, notes, and snippets.

View joseadrian's full-sized avatar

Joseadrian Ochoa joseadrian

View GitHub Profile
@joseadrian
joseadrian / fbappbookmark.js
Created June 6, 2012 19:57
Add a Facebook app bookmarklet
/* Add it as a bookmark an click it when you are on the Config page of the app, or any Facebook Tab.
This works for the following url formats:
- http[s]://[www.]facebook.com/pagename/app_APPID
- http[s]://[www.]facebook.com/pagename?sk=app_APPID.
- http[s]://[www.]developers.facebook.com/apps/APP_ID[/summary[/... ?...]]
- http[s]://[www.]facebook.com/pages/[pagename]/[page_id]?sk=app_APPID[&app_data=...]
If you are not on any of these links... it will ask your for the App ID
*/
// Bookmarlet
@joseadrian
joseadrian / bookmarklet.config.js
Created July 11, 2012 17:57
Bookmarklet: Direct Link Config Fb App
(function(){
var regex = /(?:^https?:\/\/(?:www\.)?(?:developers\.)?facebook.com\/(?:apps\/)?(?:.+(?:\/|\?sk=))(?:app_)?)([0-9]{15})(?:.+)?/;
if( (app_id = location.href.match(regex)) != null )
{
location.href= 'https://developers.facebook.com/apps/'+app_id[1]+'/summary';
}
})();
// Bookmarklet
(function(){ var regex = /(?:^https?:\/\/(?:www\.)?(?:developers\.)?facebook.com\/(?:apps\/)?(?:.+(?:\/|\?sk=))(?:app_)?)([0-9]{15})(?:.+)?/; if( (app_id = location.href.match(regex)) != null ) location.href= 'https://developers.facebook.com/apps/'+app_id[1]+'/summary'; })();
@joseadrian
joseadrian / batch_request_photo.php
Created September 15, 2012 04:38
Subir foto con Batch Request
array(
'method' => 'POST',
'name' => 'foto',
'relative_url' => '/me/photos',
'body' => http_build_query(array(
'message' => 'Test!',
'url' => 'http://creative.ak.fbcdn.net/ads-ak-snc7/s110x80/v565063/flyers/125/39/13467109601528432494_10_ce7bfdee.jpg'
)),
'omit_response_on_success' => false
),
@joseadrian
joseadrian / gist:4506818
Created January 10, 2013 23:53
Facebook https photos error
profile.ak.fbcdn.net/ => fbcdn-profile-a.akamaihd.net/
sphotos-f.ak.fbcdn.net/ => fbcdn-sphotos-f-a.akamaihd.net/
@joseadrian
joseadrian / base.html
Created February 5, 2013 21:20
Cross browser vertical aligment. From: http://csscreator.com/node/20471
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<style type="text/css" media="screen">
#container{ height: auto; min-height: 100%; }
</style>
</head>
@joseadrian
joseadrian / estilos.css
Created March 19, 2013 15:30
Posicionar elemento al centro horizontal y verticalmente
* {margin: 0;padding: 0}
html,body {height: 100%}
#table {
height: 100%;
display: table;
width: 100%;
}
@joseadrian
joseadrian / gist:5416308
Created April 18, 2013 21:18
Redimensionar imágenes manteniendo el ratio para un máximo ancho y alto.
var redimensionar = function(srcWidth, srcHeight, maxWidth, maxHeight) {
var ratio = [maxWidth / srcWidth, maxHeight / srcHeight ];
ratio = Math.min(ratio[0], ratio[1]);
// Mantener el ancho y alto normal?
if(ratio < 1){
srcWidth = srcWidth*ratio;
srcHeight = srcHeight*ratio;
}
[
{
"keys": ["super+alt+shift+5"],
"command": "set_layout",
"caption" : "1-2 Grid",
"args":
{
"cols": [0.0, 0.5, 1.0],
"rows": [0.0, 0.5, 1.0],
"cells":
@joseadrian
joseadrian / gist:5685928
Created May 31, 2013 15:49
Calculate number of lines depending on line-height (jQuery). The line-height should be set
var numberOfLines = element[0].offsetHeight / element.css('lineHeight').replace('px','');
@joseadrian
joseadrian / analytics.ajax.html
Last active May 11, 2016 03:26
Registro de evento o página para obtener conteo de registrados utilizando Google Analytics
<!--
Ejemplo:
Página: dominio/formulario
API: analytics.js
-->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)