This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tempC: Double { | |
get { | |
return temp - 273.15 | |
} | |
} | |
var tempF: Double { | |
get { | |
return tempC * 9/5 + 32 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Social | |
import MessageUI | |
class ViewController: UIViewController, MFMessageComposeViewControllerDelegate { | |
// MARK: Social | |
func postToFaceBook() { | |
let vc = SLComposeViewController(forServiceType: SLServiceTypeFacebook) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make a view with date picker and done button | |
func makeDatePickerWithDoneButton() { | |
let inputView = UIView(frame: CGRectMake(0,0, self.view.frame.width, 240)) | |
var datePicker = UIDatePicker(frame: CGRect(x: 0, y: 40, width: 0, height: 0)) | |
datePicker.datePickerMode = .Date | |
inputView.addSubview(datePicker) | |
datePicker.addTarget(self, action: Selector("handleDatePicker:"), forControlEvents: .ValueChanged) | |
let doneButton = UIButton(frame: CGRect(x: (self.view.frame.size.width/2) - (100/2), y: 0, width: 100, height: 50)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img.alignright { | |
float: right; margin: 0 0 1em 1em; | |
} | |
img.alignleft { | |
float: left; margin: 0 1em 1em 0; | |
} | |
img.aligncenter { | |
display: block; | |
margin-left: auto; | |
margin-right: auto; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use this in the content of a post or page. | |
// [get_images size="thumbnail" num=3] | |
// The code below is added to your functions.php | |
function get_images_func( $atts ) { | |
global $post; | |
$num = $atts["num"]; | |
$size = $atts["size"]; | |
$image_html = ""; // Hello World $size"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This function fetches all of the images uloaded to the current post. | |
Pass in the image size, and the number of images to return. | |
Use this function in the loop. | |
*/ | |
function get_images_in_current_post( $size="thumbnail", $num=-1 ) { | |
global $post; | |
$attachments = get_posts( array("numberposts" => $num, | |
"post_type" => "attachment", | |
"post_parent" => $post->ID, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Register a dynamic sidebar | |
// https://codex.wordpress.org/Function_Reference/register_sidebar | |
// The code below goes into functions.php | |
register_sidebar( array( | |
"name"=>"Footer Column 1", | |
"id"=>"footer-col-1", | |
"description"=>"Footer Column 1" | |
)); | |
// Add this code to your theme to display this widget: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If your site plans to make use of JQuery you can have WP load JQuery with: | |
// Add JQuery to WP | |
function theme_init() { | |
if (!is_admin()) { | |
wp_enqueue_script('jquery'); | |
} | |
} | |
theme_init(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Activate Post thumbnails | |
// http://codex.wordpress.org/Post_Thumbnails | |
add_theme_support( "post-thumbnails" ); | |
// To set up images sizes for use with post-thumbnails use the Simple Images Sizes Plugin: | |
// http://wordpress.org/extend/plugins/simple-image-sizes/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Register a custom menu named Main Menu | |
// http://codex.wordpress.org/Function_Reference/register_nav_menu | |
// register_nav_menu( $location, $description ); | |
register_nav_menu( "main-menu", "Main Menu" ); |