Skip to content

Instantly share code, notes, and snippets.

angular.module('ymusica').controller('AlbumSearch', ['$scope', 'Albums', 'Artists', '$q', function($scope, albums, artists, $q) {
$scope.albums = [];
$scope.artists = [];
var terms = new Rx.Subject();
$scope.searchMusic = terms.onNext.bind(terms);
terms.sample(250)
@toddsby
toddsby / jsontopost.php
Created April 2, 2014 18:08
JSON to $_POST php
$content_type_args = explode(‘;’, $_SERVER['CONTENT_TYPE']); // parse content_type string
if ($content_type_args[0] == ‘application/json’) {
$_POST = json_decode(file_get_contents(‘php://input’),true); // store decoded json in $_POST object
}
// Modifies $httpProvider for correct server communication (POST variable format)
angular.module('http-post-fix', [], function($httpProvider) {
// This code is taken from http://victorblog.com/2012/12/20/make-angularjs-http-service-behave-like-jquery-ajax/
// Use x-www-form-urlencoded Content-Type
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
// Override $http service's default transformRequest
$httpProvider.defaults.transformRequest = [function(data) {
/**
@toddsby
toddsby / functions.php
Last active August 29, 2015 13:56
Exclude pages from wordpress 'at a glance' aka right now widget using wp_count_posts filter
<?php
/**
* Function to retrive page id by slug
* @param string - page slug name
* @return int - page id
*/
function toddsby_get_page_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
/**
* Remove the slug from published post permalinks. Only affect our CPT though.
*/
function wpex_remove_post_type_slug( $post_link, $post, $leavename ) {
if ( ! in_array( $post->post_type, array( 'YOUR_POST_TYPE' ) ) || 'publish' != $post->post_status )
return $post_link;
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
<?php
/*
Plugin Name: Rewrite Rule Tutorials
*/
add_action( 'init', 'pmg_rewrite_add_rewrites' );
function pmg_rewrite_add_rewrites()
{
add_rewrite_endpoint( 'json', EP_PERMALINK );
add_rewrite_rule(
<?php
/*
Plugin Name: Replace Hasher
Plugin URI: http://christopherdavis.me
Description: Replace the `wp_hash_password` function
Author: Christopher Davis
Author URI: http://christopherdavis.me
License: MIT
Copyright (c) 2012 Christopher Davis
<div ng-repeat="m in milestone_choices" class="row-fluid">
<label><input type="radio" name="meaningless" value="(( $index ))" ng-model="milestone_data.index" />
&nbsp;<span ng-bind="m.title"></span></label>
</div>
/**
* Description:
* removes white space from text. useful for html values that cannot have spaces
* Usage:
* {{some_text | nospace}}
*/
app.filter('nospace', function () {
return function (value) {
return (!value) ? '' : value.replace(/ /g, '');
<?php
/* Filter to the post_class. */
add_filter( 'post_class', 'remove_class' );
/**
* Remove class from post_class() function.
*/
function remove_class( $classes ) {
$classes = array_diff( $classes, array( 'hentry' ) ); // seperate with commas for more than one class.
return $classes;