Skip to content

Instantly share code, notes, and snippets.

request_token_base_string = 'POST&' + CGI.escape("#{Pazienti2::Application::BLOG_URL}oauth1/request") + "&" + request_token_url.query
hmac = OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), params[:oauth_consumer_secret].encode("ASCII") + '&' + '', request_token_base_string.encode("ASCII"))
signature = Base64.encode64(hmac).chomp
request_token_params[:oauth_signature] = signature
(function($){
$(document).ready(function(){
$('a').click(function(e){
var el = $(this).prev('input[type="checkbox"]');
if(el.is(':checked')){
el.prop('checked',false);
}
$.ajax({
url : 'http://localhost/wordpress/wp-admin/admin-ajax.php',
type : 'POST',
<?php
public function posts_by_day() {
global $json_api, $post;
$days = array();
add_filter( 'posts_where', array( $this, 'filter_where' ) );
$query = new WP_Query( array(
'post_type' => array('post', 'imported_content' ),
'posts_per_page' => -1,
) );
if( $query->have_posts() ): while( $query->have_posts() ): $query->the_post();
<?php
public function posts_by_day() {
global $json_api, $post;
$days = array();
$query = new WP_Query( array(
'post_type' => array( ),
'posts_per_page' => -1,
) );
if( $query->have_posts() ): while( $query->have_posts() ): $query->the_post();
if( !isset( $days[ get_the_time( 'Y-m-d' ) ] ) )
@ninnypants
ninnypants / jqready.sublime-snippet
Created June 21, 2012 17:04
Sublime Text 2 snippet for $(document).ready()
<snippet>
<content><![CDATA[
<script>
jQuery(function(\$) {
${1://put all your jQuery goodness in here.}
});
</script>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>jqready</tabTrigger>
@ninnypants
ninnypants / avada_kedavra.php
Created March 28, 2012 06:38
Avada Kedavra
<?php
function avada_kedavra() {
if(round(rand())){
return 'Rebound!!!! Dodge?';
}
die('Avada Kedavra!!!!');
}
@ninnypants
ninnypants / gist:1936312
Created February 28, 2012 23:58
Custom Field Post View Counter
<?php
/*
For a simple way to keep track of the number of post views, paste this snippet into the functions.php, and then follow steps 1 and 2.
*/
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count=='' || $count==0){
delete_post_meta($postID, $count_key);
@ninnypants
ninnypants / sopa.php
Created January 18, 2012 05:40 — forked from whyisjake/sopa.php
SOPA Redirect - Fixed dates to be in the proper format
<?php
add_action( 'init', 'make_sopa_blackout' );
function make_sopa_blackout() {
if ( ! is_admin() ) {
$current_time = current_time( 'timestamp' );
$start_time = strtotime( '2012/01/17 8:00' );
$end_time = strtotime( '2012/01/17 20:00' );
if( $current_time >= $start_time && $current_time <= $end_time ) {
wp_redirect( 'http://oreilly.com/make-blackout.html', 503 );
@ninnypants
ninnypants / functions.php
Created November 17, 2011 05:41 — forked from whyisjake/functions.hp
kits functions
<?php
//error_reporting(E_ALL);
if ( function_exists( 'wpcom_is_vip' ) && wpcom_is_vip() ) {
// Load the WordPress.com dependent helper file
wpcom_vip_load_helper_wpcom(); // vip-helper-wpcom.php
} else {
// These two plugins are automatically loaded on WordPress.com
require_once( WP_CONTENT_DIR . '/themes/vip/plugins/vip-do-not-include-on-wpcom/vip-local-development-helper/vip-local-development-helper.php' );
require_once( WP_CONTENT_DIR . '/themes/vip/plugins/vip-do-not-include-on-wpcom/vip-powered-wpcom/vip-powered-wpcom.php' );
@ninnypants
ninnypants / js_add_review.php
Created November 17, 2011 05:10 — forked from whyisjake/gist:1372394
functions for make:projects
function js_add_review($content) {
global $post;
$content = $content.js_ratings_box();
$guide = get_post_custom_values('MakeProjectsGuideNumber');
if (isset($guide[0])) {
$content .= js_make_project($guide);
}
return $content;
}