Skip to content

Instantly share code, notes, and snippets.

View jshcrowthe's full-sized avatar

Josh Crowther jshcrowthe

View GitHub Profile
@jshcrowthe
jshcrowthe / ngRoute.js
Created January 17, 2014 06:13
AngularJS $ngRoute Template
app.config(function($routeProvider) {
$routeProvider.when("/",
{
controller: "",
templateUrl: ""
}).when("/",
{
controller: "",
templateUrl: ""
})
@jshcrowthe
jshcrowthe / ngHttp.js
Last active January 3, 2016 17:29
AngularJS $http Template
$http({
url: "",
method: "",
}).success(function(data, status, headers, config) {
$scope.data = data;
}).error(function(data, status, headers, config) {
$scope.status = status;
});
@jshcrowthe
jshcrowthe / ngController.js
Created January 21, 2014 03:09
AngularJS $ngController Template
app.controller('Controller_Name', function($scope) {
});
@jshcrowthe
jshcrowthe / wpWidget-Include.php
Last active August 29, 2015 13:55
Wordpress Widget Include
<?php if ( dynamic_sidebar('example_widget_area_name') ) : endif; ?>
@jshcrowthe
jshcrowthe / wpWidget-register.php
Created January 30, 2014 01:42
Wordpress Widget Register
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => 'Sidebar Widgets',
'id' => 'sidebar-widgets',
'description' => 'These are widgets for the sidebar.',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>'
));
@jshcrowthe
jshcrowthe / phpPDOConnect.php
Created January 31, 2014 21:08
PHP PDO Database Connect
function dbConnect($sql_hostName, $sql_Username, $sql_Password, $dbName = '') {
$server = $sql_hostName;
$name = $dbName;
$username = $sql_Username;
$password = $sql_Password;
$dsn = 'mysql:host='.$server.';dbname='.$name;
try {
$db = new PDO($dsn, $username, $password);
return $db;
@jshcrowthe
jshcrowthe / phpSetCookie.php
Created January 31, 2014 21:24
PHP Set Cookie
<?php
$name = 'COOKIE_NAME';
$value = 'VALUE';
$expireTime = strtotime('+1 years');
$path = '/';
setcookie($name,$value,$expireTime,$path);
?>
@jshcrowthe
jshcrowthe / phpPDOQuery.php
Created February 7, 2014 21:43
PHP PDO Database Query
function dbQuery($conn, $sql='SELECT *', $params) {
$queryTerms = explode(" ", $sql);
$toBind = array();
foreach ($queryTerms as $term) {
if ($term[0] == ':') {
array_push($toBind, $term);
}
}
try {
$stmt = $conn->prepare($sql);
@jshcrowthe
jshcrowthe / WP-Plugin-Header.php
Created February 18, 2014 22:46
Wordpress Plugin Header
<?php
/**
* Plugin Name:
* Plugin URI:
* Description:
* Version:
* Author: Josh Crowther
* Author URI: http://joshcrowther.com
* License: GPL2
*/
@jshcrowthe
jshcrowthe / WPCustomPostLook.php
Created March 11, 2014 14:53
Wordpress Custom Post Type Loop
<?php $loop = new WP_Query( array( 'post_type' => 'custom_post_type_name', 'posts_per_page' => 100 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php the_post_thumbnail(); ?>
<h3><?php the_title() ?></h3>
<a href="<?php the_permalink() ?>">Read More</a>
<?php endwhile; ?>