This file contains 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
# Your init script | |
# | |
# Atom will evaluate this file each time a new window is opened. It is run | |
# after packages are loaded/activated and after the previous editor state | |
# has been restored. | |
# | |
# An example hack to log to the console when each text editor is saved. | |
# | |
# atom.workspace.observeTextEditors (editor) -> | |
# editor.onDidSave -> |
This file contains 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
extension ViewController: UITableViewDataSource, UITableViewDelegate { | |
// As long as `total` is the last case in our TableSection enum, | |
// this method will always be dynamically correct no mater how many table sections we add or remove. | |
func numberOfSections(in tableView: UITableView) -> Int { | |
return TableSection.total.rawValue | |
} | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
// Using Swift's optional lookup we first check if there is a valid section of table. |
This file contains 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
let MovieData = [ | |
["title": "Jason Bourne", "cast": "Matt Damon, Alicia Vikander, Julia Stiles", "genre": "action"], | |
["title": "Suicide Squad", "cast": "Margot Robbie, Jared Leto, Will Smith", "genre": "action"], | |
["title": "Star Trek Beyond", "cast": "Chris Pine, Zachary Quinto, Zoe Saldana", "genre": "action"], | |
["title": "Deadpool", "cast": "Ryan Reynolds, Morena Baccarin, Gina Carano", "genre": "action"], | |
["title": "London Has Fallen", "cast": "Gerard Butler, Aaron Eckhart, Morgan Freeman, Angela Bassett", "genre": "action"], | |
["title": "Ghostbusters", "cast": "Kate McKinnon, Leslie Jones, Melissa McCarthy, Kristen Wiig", "genre": "comedy"], | |
["title": "Central Intelligence", "cast": "Dwayne Johnson, Kevin Hart", "genre": "comedy"], | |
["title": "Bad Moms", "cast": "Mila Kunis, Kristen Bell, Kathryn Hahn, Christina Applegate", "genre": "comedy"], | |
["title": "Keanu", "cast": "Jordan Peele, Keegan-Michael Key", "genre": "comedy"], |
This file contains 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
class ViewController: UIViewController { | |
// The magic enum to end our pain and suffering! | |
// For the most part the order of our cases do not matter. | |
// What is important is that our first case is set to 0, and that our last case is always `total`. | |
enum TableSection: Int { | |
case action = 0, comedy, drama, indie, total | |
} | |
// This is the size of our header sections that we will use later on. |
This file contains 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
public class Singleton<T>: MonoBehaviour where T: MonoBehaviour { | |
protected static T instance; | |
// Returns the instance of this singleton. | |
public static T Instance { | |
get { | |
if (instance == null) { | |
instance = (T)FindObjectOfType(typeof(T)); | |
if (instance == null) { |
This file contains 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
# Template when looking at a recursive function: | |
# | |
# If base case, then end recursion | |
# else reducation case, and call recursively | |
# Example: Adding together all the elements of an array. | |
def sum(numbers_array) | |
# Base Case: Is the array empty? | |
if numbers_array.empty? | |
return 0 |
This file contains 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
class LinkedListNode | |
attr_accessor :value, :next_node | |
def initialize(value, next_node=nil) | |
@value = value | |
@next_node = next_node | |
end | |
end | |
def reverse_list(list, previous=nil) |
This file contains 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 fitTextToWidth = function(node, width) { | |
var nodeWidth = node.getBBox().width; | |
if (nodeWidth > width) { | |
var $node = $(node); | |
var fontSize = $node.css('font-size'); | |
fontSize = parseInt(fontSize.substring(0, fontSize.length - 2)); | |
fontSize--; | |
if (fontSize > 0) { | |
$node.css('font-size', fontSize + 'px'); | |
fitTextToWidth(node, width); |
This file contains 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
// | |
// AngleGradientBorderView.swift | |
// AngleGradientBorderTutorial | |
// | |
import UIKit | |
class AngleGradientBorderView: UIView { | |
// Constants |
This file contains 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
// | |
// AngleGradientBorderLayer.swift | |
// AngleGradientBorderTutorial | |
// | |
import UIKit | |
class AngleGradientBorderLayer: AngleGradientLayer { | |
// Properties |
NewerOlder