Skip to content

Instantly share code, notes, and snippets.

View gnuget's full-sized avatar

David Valdez gnuget

View GitHub Profile
@gnuget
gnuget / Hide the posts created using a write panel
Created October 5, 2009 09:12
Hide the posts created using a write panel
function exclude_writepanels_posts($where){
global $wpdb, $parent_file;
if( $parent_file != 'edit.php' ) return $where;
if (empty($_GET['filter-posts'])){
$where = $where . " AND 0 = (SELECT count($wpdb->postmeta.meta_value)
FROM $wpdb->postmeta WHERE $wpdb->postmeta.post_id = $wpdb->posts.ID and $wpdb->postmeta.meta_key = '_mf_write_panel_id')";
}
return $where;
<?php
/**
* Magic Fields's debug Class
*
* @package Magic Fields
* @subpackage tools
*/
class Debug{
/**
<?php
//old way (and with this doesn't work the drag and drop order feature)
$my_group = getGroupDuplicates("some_field");
for($i=1;$i <= $my_group;$i++){
echo get('some_Field',$i);
}
//new way
$the_order = getGroupOrder('some_field');
def recu(x):
li = []
lista = []
li.append('numero')
while x > 1:
if x % 2:
x = x * 3 + 1
lista.append(x)
else:
x = x / 2
#getting all posts related with a write panel in magicfields
select * from wp_posts where wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending' OR wp_posts.post_status = 'private') AND 0 < (SELECT count(wp_postmeta.meta_value) FROM wp_postmeta WHERE wp_postmeta.post_id = wp_posts.ID and wp_postmeta.meta_key = '_rc_cwp_write_panel_id' and wp_postmeta.meta_value = '{$write_panel_id}');
<?php
$my_field_order = getGroupOrder('field');
foreach($my_field_order as $value){
$element = get('field',$value);
}
?>
<?php
function getGroupOrder($field){
global $post,$wpdb;
$elements = $wpdb->get_results("SELECT group_count FROM ".RC_CWP_TABLE_POST_META." WHERE post_id = ".$post->ID." AND field_name = '{$field}' ORDER BY order_id ASC");
foreach($elements as $element){
$order[] = $element->group_count;
}
@gnuget
gnuget / gist:130856
Created June 16, 2009 19:57
get your ip address using python
#!/usr/bin/env python
import re
import urllib2
class get_ip:
def __init__(self):
pass
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#Author: David Valdez
#Correo: david.valdez210[arroba]gmail.com
#Commands:
# rola.py
version = "1.0"
@gnuget
gnuget / ajax.js
Created February 8, 2009 02:21
example about how use livequery (jquery plugin)
//Amarramos a las anchors un evento
$(document).ready(function(){
$("a").livequery('click',function(event){
alert("hola mundo!");
});
});
//Con livequery unicamente nos preocupamos por hacer nuesta llamada
//live query se encarga de re-ligar los eventos :D
$.ajax({