Skip to content

Instantly share code, notes, and snippets.

View andergmartins's full-sized avatar

Anderson Grüdtner Martins andergmartins

View GitHub Profile
@andergmartins
andergmartins / 0_reuse_code.js
Created October 10, 2013 01:41
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@andergmartins
andergmartins / ssh-config-github-multiple-deploy-keys
Last active January 3, 2016 14:39
When using a CI server, like Jenkins, in conjunction with github, you may wish to use multiple deploy keys (github-speak for an rsa key pair that has been assigned to a single repo, rather than a user) to allow Jenkins to pull code from the github repositories
# In the example here, where three repos are used, the idea is to take advantage of ssh's config mechanism
# For use with Jenkins, do the following:
# login to your CI Server
sudo su -s /bin/bash jenkins
cd ~/.ssh/
# then create three key key pairs
ssh-keygen -f id_rsa_project1
# on prompt, set target file to id_rsa_project1
# repeat for id_rsa_project2 and id_rsa_project3
@andergmartins
andergmartins / index.html
Last active August 29, 2015 13:56
HTML5 Multiple Files Upload
<html>
<head>
<style type="text/css" media="screen">
input {
display: block;
margin-top: 10px;
}
#modal {
background-color: #affdc2;
@andergmartins
andergmartins / select2_fixed_widgets.py
Last active August 29, 2015 13:57 — forked from BertrandBordage/gist:8288704
Fix a wrong class name
# WARNING: This is just a workaround. Consider it as a very
# temporary solution if you really need this feature.
from django.utils.safestring import mark_safe
from django_select2.util import convert_to_js_arr
TEMPORARY_ID = 0
<?php
// no direct access
defined('_JEXEC') or die;
// Variables
$doc = JFactory::getDocument();
$user = JFactory::getUser();
$template = 'templates/' . $this->template;
// get html head data
tell application "Finder"
try
set appPath to (path to application "Evernote" as text)
on error
display dialog "Couldn't find Evernote. Is it installed?"
end try
set printPath to (path to "dlib" from user domain as text) & "PDF Services"
make new alias at printPath to appPath with properties {name:"Send PDF to Evernote"}
end tell
@andergmartins
andergmartins / update-site.sh
Created September 30, 2014 23:20
Code to synchronize your copy of a site
#!/bin/sh
################################################################################
# DEFAULT VARIABLES
################################################################################
LOCAL_PATH=/var/www
LOCAL_DOMAIN=mylocaltest.dev
LOCAL_DB_NAME=myuser
LOCAL_DB_USER=root
LOCAL_DB_PASSWORD=myrootpassword
@andergmartins
andergmartins / extract-string.sql
Created January 8, 2015 15:11
Extract data from JSON string inside a MySQL field. In this case, extract metadesc and page title from the menu params
SELECT m.id, m.title,
@tmp_search := '"menu-meta_description":"' AS tmp_search,
@tmp_search_len := LENGTH(@tmp_search) AS tmp_search_len,
@start := LOCATE(@tmp_search, m.params) AS tmp_start,
@end := LOCATE('"', m.params, @start + @tmp_search_len) AS tmp_end,
SUBSTRING(m.params, @start + @tmp_search_len, @end - @start - @tmp_search_len) AS metadesc,
@tmp_search := '"page_title":"' AS tmp_search,
@tmp_search_len := LENGTH(@tmp_search) AS tmp_search_len,
@start := LOCATE(@tmp_search, m.params) AS tmp_start,
@andergmartins
andergmartins / json-debug
Created March 25, 2015 19:03
JSON debug
$json_errors = array(
JSON_ERROR_NONE => 'No error has occurred',
JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded',
JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON',
JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
JSON_ERROR_SYNTAX => 'Syntax error',
JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded (PHP 5.3.3)',
JSON_ERROR_RECURSION => 'One or more recursive references in the value to be encoded (PHP 5.5.0)',
JSON_ERROR_INF_OR_NAN => 'One or more NAN or INF values in the value to be encoded (PHP 5.5.0)',
JSON_ERROR_UNSUPPORTED_TYPE => 'A value of a type that cannot be encoded was given (PHP 5.5.0)'
@andergmartins
andergmartins / plugin.js
Last active March 2, 2016 00:29
Wistia Player Custom Plugin
/**
* @package MyPlugin
* @license http://www.gnu.org/licenses/gpl.html GNU/GPL
*/
/* global Wistia */
Wistia.plugin('myplugin', function(video) {
// Wait for the video element to be fully loaded
interval = setInterval(function() {
// Your magic goes here