Skip to content

Instantly share code, notes, and snippets.

View jonathanwork's full-sized avatar

Jonathan Lopez jonathanwork

View GitHub Profile
@jonathanwork
jonathanwork / find_IP.js
Created May 4, 2017 04:43
getting ip address of the current page
$.getJSON( "//freegeoip.net/json/" + window.location.host + "?callback=?", function(data) {
console.warn('Fetching JSON data...');
// Log output to console
console.info(JSON.stringify(data, null, 2));
});
<video loop autoplay>
<source src="LAEPANIMACION/slidenuevo.mp4" type="video/mp4">
</video>
@jonathanwork
jonathanwork / chatServer.js
Created May 2, 2017 07:04 — forked from creationix/chatServer.js
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@jonathanwork
jonathanwork / geome.js
Created April 28, 2017 02:13
get clients ip geolocation.
$(document).ready(function () {
$.getJSON("https://jsonip.com/?callback=?", function (data) {
console.log(data);
alert(data.ip);
});
});
@jonathanwork
jonathanwork / geo.js
Last active April 9, 2017 22:10
geolocation in javascript ;)
navigator
.geolocation
.getCurrentPosition(position=> {
var lat = position.coords['latitude'];
var lng = position.coords['longitude'];
console.log(`your current location is ${lat}, ${lng}`);
})
@jonathanwork
jonathanwork / geo.js
Created April 9, 2017 22:08
geolocation in javascript ;)
navigator
.geolocation
.getCurrentPosition(position=> {
var lat = position.coords['latitude'];
var lng = position.coords['longitude'];
console.log(lat, lng);
})
@jonathanwork
jonathanwork / power_function.sass
Created March 20, 2017 09:29
power function in sass
@function pow($number, $exponent)
@if (round($exponent) != $exponent)
@return exp($exponent * ln($number))
$value: 1
@if $exponent > 0
@for $i from 1 through $exponent
$value: $value * $number
@jonathanwork
jonathanwork / mongodbRecords.js
Created January 3, 2017 06:38
getting the records and the content of a collection
//JUST to show record within mongodb
var collections = db.getCollectionNames();
print('Collections inside the db:');
for(var i = 0; i < collections.length; i++){
var name = collections[i];
if(name.substr(0, 6) != 'system')
print(name + ' - ' + db[name].count() + ' records');
}
@jonathanwork
jonathanwork / lookinCollections.js
Created January 3, 2017 05:24
this will look into all your collections within mongoDB
var collections = db.getCollectionNames();
for(var i = 0; i< collections.length; i++){
print('Collection: ' + collections[i]); // print the name of each collection
db.getCollection(collections[i]).find().forEach(printjson); //and then print the json of each of its elements
}
@jonathanwork
jonathanwork / gulpfile.js
Created December 25, 2016 23:32
reallly helpful gist to use with hapi and gulpfile with browserSync and nodemon
/**
* Module Dependencies
*/
var gulp = require('gulp');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var nodemon = require('gulp-nodemon');
var g_sass = require('gulp-sass');
var pug = require('gulp-pug');