Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Jorge Morales morales2k

🏠
Working from home
View GitHub Profile
@morales2k
morales2k / make_links
Created Apr 18, 2014
Function to make links inside blobs of text by matching urls and replacing them with the links... includes support for cyrilic characters... still has some quirks to work out... but it works on pretty much all cases as far as I have tested it... feel free to suggest improvements! :)
View make_links
@morales2k
morales2k / getCookie.js
Created May 29, 2014
doSomething in js based on wether or not a cookie is set with the getCookie function
View getCookie.js
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
}
else
{
@morales2k
morales2k / preg_match magic.php
Last active Aug 29, 2015
Youtube regex to extract video id from most youtube urls... from stack overflow answer: http://stackoverflow.com/a/17030234/1591301
View preg_match magic.php
$yturl = 'http://youtu.be/0f4qZkd4npM';
/*
other possible urls...
youtube.com/v/vidid
youtube.com/vi/vidid
youtube.com/?v=vidid
youtube.com/?vi=vidid
youtube.com/watch?v=vidid
youtube.com/watch?vi=vidid
youtu.be/vidid
@morales2k
morales2k / videoData.class.php
Created Jul 31, 2014
Get youtube video info and embed code from input youtube url. Can be easily modified to use different "part" queries... but I'm doing just the snippet and player ones here...
View videoData.class.php
<?php
class videoData{
static $videoId = '';
static $videoData = array();
static private $apiKey = '[YOUR_API_KEY_HERE]';
static $url = 'https://www.googleapis.com/youtube/v3/videos?id=@@VIDEOID@@&part=snippet,player&key=@@APIKEY@@';
static $lastURL = '';
static function getIdFromURL($url){
@morales2k
morales2k / UserDataHelper.php
Created Sep 24, 2014
PHP-Fusion class to fetch user data.
View UserDataHelper.php
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) PHP-Fusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: UserDataHelper.php
| Author: Jorge Morales (Elvenelf / EffectiX.Net)
+--------------------------------------------------------+
| This program is released as free software under the
@morales2k
morales2k / bumpver.sh
Created Oct 2, 2015
Bump deployed version tag inside .env file. For use with Envoyer.io and Laravel 5 to update a VERSION var inside the .env file of your Envoyer releases.
View bumpver.sh
#! /bin/bash
archivo='.env'
filelines=`cat $archivo`
i=0
newfilelines=''
echo "Fetching dirty tags from remote repository..."
gitVersion=`git ls-remote -t {{REPOSITORY-URL}} *.*.*^*`
gv=''
@morales2k
morales2k / default.sublime-keymap
Last active Dec 20, 2015
Sublime Text 2 reindent full document shortcut keybinding. This gist is to be added to user keybindings to set f12 key to issue the reindent command to the complete document instead of doing it to a single line as it does when doing it from the menu. One normally selects all the document before doing this command from the menu, with the argument…
View default.sublime-keymap
[
{
"keys": ["f12"],
"command": "reindent",
"args": {
"single_line": false
}
}
]
@morales2k
morales2k / gist:6193580
Last active Dec 20, 2015
Google Analytics function for custom events for analytics.js Use it anyway you want, from simply adding onclick attribute to an element other than <a> to track a click event. Easily customizable to make it track other stuff besides event hitType, or click action for that matter. See analytics.js documentation https://developers.google.com/analyt…
View gist:6193580
/*!
* Tracking function to be used with the new analytics.js (i,s,o,g,r,a,m) snippet
* @param el string Identifier for the tracking click event
* @author Jorge L. Morales (EffectiX.Net)
* @return void
*/
function gaTrack(el){
ga('send',
{
'hitType': 'event',
@morales2k
morales2k / gaq.push
Created Nov 7, 2013
Google Analytics -> One push, multiple UA tracking codes.
View gaq.push
_gaq.push(
['_setAccount', 'UA-XXXXX-1'],
['_trackPageview'],
['b._setAccount', 'UA-XXXXX-2'],
['b._trackPageview']
);
@morales2k
morales2k / jquery-sidr.js
Created Jul 8, 2014
The jquery-sidr fix that made it work for me in all browsers. Try it out and see if it helps!
View jquery-sidr.js
/*
* Sidr
* https://github.com/artberri/sidr
*
* Copyright (c) 2013 Alberto Varela
* Licensed under the MIT license.
*/
;(function( $ ){
You can’t perform that action at this time.