Skip to content

Instantly share code, notes, and snippets.

View joseadrian's full-sized avatar

Joseadrian Ochoa joseadrian

View GitHub Profile
@joseadrian
joseadrian / get.js
Created September 26, 2013 06:02
GET en javascript
var GET = function () {
var vars = {},
parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function ( m, key, value ) {
vars[key] = value;
});
return vars;
};
@joseadrian
joseadrian / command.js
Last active December 27, 2015 12:29
Show link to install app from: - developers.facebook.com/apps/APP_ID - http://facebook.com/PAGE_USERNAME/app_APP_ID - http://facebook.com/pages/PAGE_NAME/PAGE_ID?v=app_APP_ID (v = sk)
var app_id = location.href.match(/(?:app(?:s\/|_))([0-9]+)/).pop();
var url = 'https://facebook.com/dialog/pagetab?app_id={app_id}&redirect_uri=http://facebook.com';
window.prompt("Copy URL [ctrl + c]", url.replace('{app_id}', app_id));
<?php
define('VERIFY_TOKEN', 'yourappssecret');
$method = $_SERVER['REQUEST_METHOD'];
if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe' && $_GET['hub_verify_token'] == VERIFY_TOKEN) {
echo $_GET['hub_challenge'];
} else if ($method == 'POST') {
$updates = json_decode(file_get_contents("php://input"), true);
@joseadrian
joseadrian / DB_active_rec.php
Last active December 28, 2015 03:29
Codeigniter paging. Methods to get info about total rows of they query using FOUND_ROWS(). ar_ prefix for versión >= 3 qb_ prefix for version < 3
<?php
/*
* Add this methos on the system/database/DB_active_rec.php file
*/
/**
*
* Method to stablish the limit and offset
*/
public function set_paging($page = 1, $results_per_page = 20)
@joseadrian
joseadrian / googlemaps.polyline.event.js
Created November 14, 2013 15:08
Google Maps: Polyline point events: dragStart and dragEnd
google.maps.event.addListener(myPolyline, 'capturing_changed', function(e) {
var path = this.getPath();
});
@joseadrian
joseadrian / maps.utils.js
Last active March 24, 2021 15:12
Google Maps. Detect if one of the points on the polyline paths intersects a circle
(function(){
var polyline = new google.maps.Polyline();
google.maps.Polyline.prototype.closestDistanceToSegment = function(center, segment)
{
var firstPoint, lastPoint, A, B, C, D, E, distanceAB, t, projection = this.getMap().getProjection();
// The other extreme of the path
lastPoint = segment[0];
@joseadrian
joseadrian / less.js
Created November 25, 2013 23:27
Crear funciones lesscss
less = {
functions: {
test: function(value, context){
// return new(tree.Dimension)(valor, unidad)
// return new(tree.Anonymous)
// return new(tree.Quoted)
// return new(tree.URL)
// return new(tree.color)(color, alpha)
}
}
@joseadrian
joseadrian / computedStyle.js
Created November 27, 2013 21:22
getComputeStyle IE support. getcomputedStyle(element, pseudo class)
// http://stackoverflow.com/questions/15733365/cross-browser-ie8-getcomputedstyle-with-javascript#comment23187887_15733365
// http://snipplr.com/view/13523/
if (!window.getComputedStyle) {
window.getComputedStyle = function(el, pseudo) {
this.el = el;
this.getPropertyValue = function(prop) {
var re = /(\-([a-z]){1})/g;
if (prop == 'float') prop = 'styleFloat';
if (re.test(prop)) {
prop = prop.replace(re, function () {
@joseadrian
joseadrian / first-example.js
Last active December 29, 2015 15:59
jQuery Lines examples
$('.first').lines({
replace: function(lines) {
var lastLine = lines[lines.length-1];
var center = $(this).width()/2 - lastLine.width/2;
lines[lines.length-1].text = '<span style="position:relative;margin-left:'+center+'px">'+lastLine.text+'</span>';
return lines;
}
});
#banner {
border: 1px solid #666;
display: block;
width: 100%;
height: 1em;
font-size: 1em;
line-height: 1em;
margin: 20px auto;
padding: 0px;
text-align: justify;