Skip to content

Instantly share code, notes, and snippets.

View djom202's full-sized avatar

Jonathan Olier djom202

View GitHub Profile
SELECT id, nombre, (6371 * ACOS(
SIN(RADIANS(lat)) * SIN(RADIANS(4.6665578))
+ COS(RADIANS(lng - -74.0524521)) * COS(RADIANS(lat))
* COS(RADIANS(4.6665578))
)
) AS distance
FROM direcciones
HAVING distance < 1 /* 1 KM a la redonda */
ORDER BY distance ASC
<?php
class Logger
{
protected $file;
public function __construct($file) { $this->file = $file; }
public function log($message)
{
$message = date('H:i:s ') . $message . PHP_EOL;
<?php
/**
* ImageManager.php
* A wrapper around GD that does multiple operations like, resizing, rotating,
* cropping and stuff.
*
* @author Michael Pratt <pratt@hablarmierda.net>
* @version 1.0
* @link http://www.michael-pratt.com/
* @demo http://www.michael-pratt.com/Lab/imageManager/
@djom202
djom202 / gulpfile.js
Created June 7, 2016 22:13 — forked from jbarrus/gulpfile.js
protractor coverage support with gulp and istanbul (not tested, this is just extracted from larger files to demonstrate how to get protractor coverage working)
var istanbul = require('istanbul'),
gulp = require('gulp'),
istanbul = require('gulp-istanbul');
gulp.task('js', function() {
return gulp.src('js')
.pipe(istanbul({
includeUntested: true,
coverageVariable: '__coverage__'
}))
@djom202
djom202 / connStatus.js
Created June 9, 2016 22:30
Verify Status Internet
window.connStatus = {
_status: null,
waitForChange: function(_callback) {
this.getState();
this.updateState(_callback);
return this;
},
updateState: function(_callback) {
console.log('Init setInterval');
setInterval(function() {
@djom202
djom202 / index.js
Last active July 18, 2016 13:56
Angular los console logs en Dev
(function() {
var IS_DEV = true;
if (window.console && console.log) {
var oldFnLog = console.log;
console.log = function() {
IS_DEV && oldFnLog.apply(this, arguments);
}
}
})();
@djom202
djom202 / setEncode.js
Created June 22, 2016 19:40
Encode Username and Password to send header via API Authorization
function setEncode(input) {
var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
chr1, chr2, chr3, enc1, enc2, enc3, enc4 = "",
output = "",
i = 0;
do {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
@djom202
djom202 / index.js
Last active September 5, 2016 16:42
A object with a promise of protractor
//***************
// Protractor is global var
//***************
var User = function(){
this.isLogged = function(){
var _defered = protractor.promise.defer();
this.httpRequest(); // Call the http request function
@djom202
djom202 / onPreparePromiseConf.js
Created September 27, 2016 14:35
Configuration using a function in onPrepare to set a parameter before
// Configuration using a function in onPrepare to set a parameter before
// testing.
var env = require('./environment.js');
var q = require('q');
// The main suite of Protractor tests.
exports.config = {
seleniumAddress: env.seleniumAddress,