Skip to content

Instantly share code, notes, and snippets.

View jorgepedret's full-sized avatar
😀
Turned on by Open Source

Jorge Pedret jorgepedret

😀
Turned on by Open Source
View GitHub Profile
@jorgepedret
jorgepedret / .htaccess
Created June 6, 2011 22:14
Prevent directory listing (htaccess)
Options -Indexes
@jorgepedret
jorgepedret / .htaccess
Created June 6, 2011 22:15
Reduce pages weight by compressing static data (htaccess)
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
@jorgepedret
jorgepedret / .htaccess
Created June 6, 2011 22:15
Automatically add utf-8 charset to files (htaccess)
<FilesMatch "\.(htm|html|css|js)$">
AddDefaultCharset UTF-8
</FilesMatch>
@jorgepedret
jorgepedret / gist:1016695
Created June 9, 2011 13:07
Gravity Forms Custom Fields
<?php
add_action("gform_field_input", "ih_gform_field_input", 10, 5);
function ih_gform_field_input($input, $field, $value, $lead_id, $form_id){
//wp_debug($field);
if($field["type"] == "vehicleyear"){
//wp_debug($field['choices']);
//$input = 'Aha!';
}
return $input;
}
<widget:div id="element_id" class="widget-html">Default text</widget:div>
@jorgepedret
jorgepedret / how-it-works.html
Created June 20, 2011 20:39
VouchFor HIW Script
<script>
$(".create, #create-link").click(function() {
$(".step-wrapper .col").removeClass('selected'); $(".create").addClass('selected');
$(".details, #hiw-intro").hide(); $("#hiw-create").show();
$('html, body').animate({scrollTop: 300}, 200);
return false;
});
$(".share, #share-link").click(function() {
$(".step-wrapper .col").removeClass('selected'); $(".share").addClass('selected');
$(".details, #hiw-intro").hide(); $("#hiw-share").show();
@jorgepedret
jorgepedret / debug.php
Created July 4, 2011 20:12
PHP nice debug
<?php
if (!function_exists('pp')) {
function pp($obj) {
$data = json_encode(print_r($obj,true));
?>
<script type="text/javascript">
var obj = <?php echo $data; ?>;
var logger = document.getElementById('bsdLogger');
if (!logger) {
logger = document.createElement('div');
@jorgepedret
jorgepedret / gist:1070901
Created July 8, 2011 01:13
quick wp stuff
<?php
funcion get_years(){
$results = $wpdb->query("SELECT DISTINCT YEAR(meta_value) as year FROM wp_postmeta WHERE meta_key = 'release_date'");
echo '<select>';
foreach($results as $result){
echo '<option>'.$result->year.'</option>';
}
echo '</select>';
}
@jorgepedret
jorgepedret / gf_placeholder.php
Created September 5, 2011 05:39
GravityForms placeholder text
<?php
/*
Add a custom field to the field editor (See editor screenshot)
*/
add_action("gform_field_standard_settings", "my_standard_settings", 10, 2);
function my_standard_settings($position, $form_id){
// Create settings on position 25 (right after Field Label)
if($position == 25){
?>
<li class="admin_label_setting field_setting" style="display: list-item; ">
@jorgepedret
jorgepedret / render.js
Created October 20, 2011 21:02
sample render function
render: function(template, payload) {
var cooq = this;
cooq.add_template_helper_vars(payload, { "user": cooq.this_user });
return ich[template](payload);
}