Skip to content

Instantly share code, notes, and snippets.

View Pushplaybang's full-sized avatar
:octocat:
0_0

Paul Pushplaybang

:octocat:
0_0
View GitHub Profile
@Pushplaybang
Pushplaybang / woo-basic-total-and-cart-count.php
Created February 1, 2014 14:48
very basic cart count / url / total
global $woocommerce; ?>
<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
<?php
/* Register custom post types on the 'init' hook. */
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 0.1.0
* @access public
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
# SYNTAX:
var pattern = new RegExp(pattern, attributes); # attributes: g (global); i (case-sensitive); m (multiline matches)
var pattern = /pattern/attributes; # same as above
# BRACKETS:
[...]: Any one character between the brackets.
[^...]: Any one character not between the brackets.
@Pushplaybang
Pushplaybang / packages
Last active August 29, 2015 14:16
My Meteor Starter Packages
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
meteor-platform
email
http
@Pushplaybang
Pushplaybang / meteor-simple-schema.js
Last active August 29, 2015 14:16
Meteor Simple Schema - re-usable snippets
/* For Use with collection2 / simpleschema / autoform */
Schemas.UsefulFields = new SimpleSchema({
createdAt : {
type: Date,
autoValue: function() {
if (this.isInsert) {
return new Date;
} else if (this.isUpsert) {
return {$setOnInsert: new Date};
} else {
@Pushplaybang
Pushplaybang / introrx.md
Last active August 29, 2015 14:18 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@Pushplaybang
Pushplaybang / rangefunction.js
Created April 25, 2015 21:39
Javascript range function
var range = function(start, end, step) {
var range = [];
var typeofStart = typeof start;
var typeofEnd = typeof end;
if (step === 0) {
throw TypeError("Step cannot be zero.");
}
if (typeofStart == "undefined" || typeofEnd == "undefined") {
@Pushplaybang
Pushplaybang / playing_cards_ex.js
Last active August 29, 2015 14:20
Playing Cards Deck module in javascript with human shuffling (rough - needs re-factoring)
// intentionally create a global
Deck = function Deck() {
// TODO : make appropriate vars settable
var Suits = ['c', 'h', 'd', 's'],
Pack = [],
cardsOut = [],
cardCount = 52,
rv = 6, // riffleVariance
cv = 10, // cutVariance
@Pushplaybang
Pushplaybang / fischer_yates_shuffle.js
Created April 27, 2015 12:21
Fischer Yates Shuffle in Javascript
//as a function
function shuffleFischerYates(arr) {
var i = arr.length, j, temp;
while (--i > 0) {
j = Math.floor(Math.random()*(i+1));
temp = arr[j];
arr[j] = arr[i];
arr[i] = temp;
}
}