Skip to content

Instantly share code, notes, and snippets.

View goshmx's full-sized avatar
💭
Build. Fail. Learn. Repeat. 👾

Gosh Hernandez goshmx

💭
Build. Fail. Learn. Repeat. 👾
View GitHub Profile
@goshmx
goshmx / degrees2meters.js
Created September 5, 2018 21:51 — forked from onderaltintas/degrees2meters.js
javascript coordinate conversions between 900913(3857) - 4326(lat lon)
var degrees2meters = function(lon,lat) {
var x = lon * 20037508.34 / 180;
var y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
y = y * 20037508.34 / 180;
return [x, y]
}
//test
lon= -77.035974
lat = 38.898717
@goshmx
goshmx / WannaCry-SMB.c
Created May 14, 2017 21:37 — forked from msuiche/WannaCry-SMB.c
WannaCry - DOUBLEPULSAR references
// https://twitter.com/msuiche
int threadMain()
{
unsigned int i; // edi@1
_DWORD *v1; // eax@2
void *v2; // esi@7
char v4; // [sp+13h] [bp-2Dh]@0
char v5; // [sp+14h] [bp-2Ch]@1
void *Memory; // [sp+18h] [bp-28h]@1
@goshmx
goshmx / CatalogoController.php
Created May 9, 2017 21:11
Laravel catalogo
<?php
class CatalogoController extends \BaseController {
public $respuesta = array(
'status' => true,
'msg' => ""
);
public $statusHttp = 200;
public $tabla;
@goshmx
goshmx / Refactoring.php
Last active July 6, 2016 04:04
Coding Refactoring
<?php
class PresentacionController extends Controller {
/**
* Cofirmación de Servicio
*
* @author gosh
* @version 1.1
@goshmx
goshmx / UserController.js
Created March 4, 2016 19:58
Consulta array de documentos en mongo usando Promises
var usuarios = [];
var consultaCursos = function(usuario) {
return new Promise(function(resolve, reject) {
if(typeof usuario.curso != 'undefined') {
if (usuario.curso != false) {
Role.findOne({id: usuario.curso})
.exec(function (err, curso) {
if (err) return reject(usuario);
usuario.cursoDoc = curso;

#How you get Sail.js running on Openshift#

This instruction is tested with:

  • Sails.js v0.9.16
  • Node.js 0.10 on Openshift ( 05 May 2014)

###1) package.json

If you use the package.json build by sails new Projectname than you have to add a few fields for openshift – so the server can start you app automatically. Sails uses Grunt to build minify css/js and so on. Openshift dont have grunt installed so you have to add this also.

@goshmx
goshmx / gist:d79cf3df9cb06804c606
Created October 13, 2015 20:19
Preview de imagen al cargar un archivo
<form id="form1" runat="server">
<input type='file' id="imgInp" />
<img id="target" src="#" alt="your image" />
</form>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#target').attr('src', e.target.result);
}
@goshmx
goshmx / ssh-telegram.sh
Last active August 29, 2015 14:27 — forked from matriphe/ssh-telegram.sh
Bash Script to notify via Telegram Bot API when user log in SSH
# save it as /etc/profile.d/ssh-telegram.sh
# use jq to parse JSON from ipinfo.io
# get jq from here http://stedolan.github.io/jq/
USERID="<target_user_id>"
KEY="<bot_private_key>"
TIMEOUT="10"
URL="https://api.telegram.org/bot$KEY/sendMessage"
DATE_EXEC="$(date "+%d %b %Y %H:%M")"
TMPFILE='/tmp/ipinfo-$DATE_EXEC.txt'
if [ -n "$SSH_CLIENT" ]; then
@goshmx
goshmx / IteraArrays.js
Created August 6, 2015 00:20
Recorre un array asociativo
/**
* Prototipo para recorrer de forma iterativa un array de arrays.
* @author @Gosh_
* @param callback function
*/
Array.prototype.IteraArrays = function (cb) {
this.forEach(function (obj, inx) {
// Si no es un array esperamos para disparar el iterador
if (obj.constructor === Array) {
obj.IteraArrays.call(obj, cb);
@goshmx
goshmx / livestream
Last active August 29, 2015 14:26 — forked from dbussert/livestream
var child_process = require('child_process'),
http = require('http');
url = require('url'),
ffmpeg = null;
var livestream = function (req, resp) {
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible).
var input = 'udp://225.1.1.1:8208';