Skip to content

Instantly share code, notes, and snippets.

@6ui11em
6ui11em / gist:1994233
Created March 7, 2012 16:35 — forked from yvesvanbroekhoven/jquery-extlink.js
JQuery: Open external link in a new window
/*
* Open external link in a new window
*/
$('a:not([href^="'+ window.location.protocol + '//' + window.location.host + '"]):not([href^="#"]):not([href^="/"])')
.attr('target', '_blank');
@6ui11em
6ui11em / php-curl-post.php
Created March 8, 2012 07:55 — forked from davidvanvickle/php-curl-post.php
PHP: Curl post and write to file
$ch = curl_init($post_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('data1'=>'val','data2'=>'val2')));
$data_str = curl_exec($ch);
curl_close($ch);
file_put_contents($path_to_xml_data,$data_str);
@6ui11em
6ui11em / gist:2004290
Created March 9, 2012 00:17
CSS: Image Replacement
.ir {
border:0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent;
}
@6ui11em
6ui11em / gist:2252065
Created March 30, 2012 14:51
CSS: Bootstrap center nav-pills in a row
.nav-tabs > li, .nav-pills > li {
float:none;
display:inline-block;
*display:inline; /* ie7 fix */
zoom:1; /* hasLayout ie7 trigger */
}
.nav-tabs {
text-align:center;
}
@6ui11em
6ui11em / ht_redirect.txt
Created May 2, 2012 17:53 — forked from crazy4groovy/ht_redirect.txt
htaccess: Redirection rules
RewriteEngine On
RewriteBase /
### Redirect www to non-www ###
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
### Redirect non-www to www ###
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
@6ui11em
6ui11em / ht_upload_filesize.txt
Created May 2, 2012 17:59
htaccess: Max upload filesize
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200
@6ui11em
6ui11em / gist:2642954
Created May 9, 2012 08:27
jQuery: Fancybox dialog / alert
function fancyAlert(msg) {
jQuery.fancybox({
'modal' : true,
'content' : "<div style=\"margin:1px;width:240px;\">"+msg+"<div style=\"text-align:right;margin-top:10px;\"><input style=\"margin:3px;padding:0px;\" type=\"button\" onclick=\"jQuery.fancybox.close();\" value=\"Ok\"></div></div>"
});
}
function fancyConfirm(msg,callback) {
var ret;
jQuery.fancybox({
@6ui11em
6ui11em / gist:2721459
Created May 17, 2012 20:38
jQuery: encode / decode HTML Entites
// Encode/decode htmlentities
function encodeEntities(s){
return $("<div/>").text(s).html();
}
function dencodeEntities(s){
return $("<div/>").html(s).text();
}
@6ui11em
6ui11em / gist:2776291
Created May 23, 2012 16:44
Symphony: Select distinct nodes
<xsl:for-each select="publishers-countries/entry">
<xsl:variable name="c" select="country/@handle" />
<xsl:if test="not(preceding-sibling::*/country/@handle = $c)">
<option>
<xsl:value-of select="country/."/>
</option>
</xsl:if>
</xsl:for-each>
@6ui11em
6ui11em / jQuery: HTML to XHTML.js
Created July 9, 2012 15:16
jQuery: HTML to XHTML
var html = jQuery('#html-element').val();
if (html != '') {
html = jQuery(html).get(0);
var xhtml = getXHTML(html);
jQuery(this).val(jQuery(xhtml).get(0).outerHTML);
}
function getXHTML(node) {