stack

def delete_first(self):
    deleted = self.head
    if self.head:
        self.head = self.head.next
        deleted.next = None
    return deleted
class Element(object):
    def __init__(self, value):
        self.value = value
        self.next = None
        
class LinkedList(object):
    def __init__(self, head=None):
        self.head = head
        
    def append(self, new_element):
        current = self.head
        if self.head:
            while current.next:
                current = current.next
            current.next = new_element
        else:
            self.head = new_element

    def insert_first(self, new_element):
        new_element.next = self.head
        self.head = new_element

    def delete_first(self):
        if self.head:
            deleted_element = self.head
            temp = deleted_element.next
            self.head = temp
            return deleted_element
        else:
            return None

class Stack(object):
    def __init__(self,top=None):
        self.ll = LinkedList(top)

    def push(self, new_element):
        self.ll.insert_first(new_element)

    def pop(self):
        return self.ll.delete_first()

classy class

This class to represent how classy someone
or something is.”Classy” is interchangable with “fancy”.
If you add fancy-looking items, you will increase
your “classiness”.

class Classy(object):
    def __init__(self):
        self.items = []

    def addItem(self, item):
    	self.items.append(item)
 
    def getclassiness(self):
    	classiness = 0
    	if len(self.items) > 0:
    		for item in self.items:
        		if item == "tophat":
    				classiness += 2
    			elif item == "bowtie":
    				classiness += 4
    			elif item == "monocle":
    				classiness += 5
    		return classiness

notation: expression
():parenthesis

“””input manatees: a list of “manatees”, where one manatee is represented by a dictionary
a single manatee has properties like “name”, “age”, et cetera
n = the number of elements in “manatees”
m = the number of properties per “manatee” (i.e. the number of keys in a manatee dictionary)”””

def example1(manatees):
for manatee in manatees:
print manatee[‘name’]

def example2(manatees):
print manatees[0][‘name’]
print manatees[0][‘age’]

def example3(manatees):
for manatee in manatees:
for manatee_property in manatee:
print manatee_property, “: “, manatee[manatee_property]

def example4(manatees):
oldest_manatee = “No manatees here!”
for manatee1 in manatees:
for manatee2 in manatees:
if manatee1[‘age’] < manatee2['age']: oldest_manatee = manatee2['name'] else: oldest_manatee = manatee1['name'] print oldest_manatee

class Element(object):
    def __init__(self, value):
        self.value = value
        self.next = None
        
class LinkedList(object):
    def __init__(self, head=None):
        self.head = head
        
    def append(self, new_element):
        current = self.head
        if self.head:
            while current.next:
                current = current.next
            current.next = new_element
        else:
            self.head = new_element
            
    def get_position(self, position):
        counter = 1
        current = self.head
        if position < 1:
            return None
        while current and counter <= position:
            if counter == position:
                return current
            current = current.next
            counter += 1
        return None
    
    def insert(self, new_element, position):
        counter = 1
        current = self.head
        if position > 1:
            while current and counter < position:
                if counter == position -1:
                    new_element.next = current.next
                    current.next = new_element
                current = current.next
                counter += 1
        elif position == 1:
            new_element.next = self.head
            self.head = new_element
    
    def delete(self, value):
        current = self.head
        previous = None
        while current.value != value and current.next:
            previous = current
            current = current.next
        if current.value == value:
            if previous:
                previous.next = current.next
            else:
                self.head = current.next

bower

sudo npm install -g bower

https://bower.io/

run bower install

var numLetters = function(letter){
	return new Function('times',
		"if (times < 0) return '';
		var result = '';
		times = Math.round(times);
		while(times--){ result += '" + letter +"'; }
		return result;"
		);
}
&#91;/javascript&#93;

&#91;javascript&#93;
<div id="beach-info"></div>
<script type="text/template" id="beach-supplies">
	<% if(supplies.empty) { %>
		<p> Whaaaat? Get to the beach anyway! </p>
	<% } %>

	<ul>
		<li> Sunscreen - <% if (supplies.sunscreen) { %> check! <% } %> </li>
		<% if (supplies.towel) { %>
			<li> Towel - Yes, a <%= supplies.towel =%> one! </li>
		<% } %>
		<li> Shades - <% if (supplies.shades) { %> check! <% } else { %> sadly, no!! <% } %></li>
	</ul>
</script>
var string = "Hi, my name is *(name)*. And I *(emotion)* this *(thing)*!";

var logResult = template( string );

logResult('Richard', 'love', 'green mint icecream', 2);

Yomen
npm install -g grunt-cli bower yo generator-karma generator-angular

click element

$('#my-elem').click(function(e){
	//the element has been clicked.. do stuff
})

document.body.innerHTML = ”;
document.body.style.background= “white”;

var num = [1, 2, 3];

for(var i = 0; i < nums.length; i++){ var num = nums[i]; var elem = document.createElement('div'); elem.textContent = num; elem.addEventListener('click', function(){ alert(num); }); document.body.appendChild(elem); } [/javascript] [javascript] getCurrentCat: function(){ return model.currentCat; }, getCats: function(){ return model.cats; }, setCurrentCat: function(cat){ model.currentCat = cat; }, incrementCounter: function(){ model.currentCat.clickCount++; catView.render(); } }; [/javascript]

sudoers


vagrant@vagrant-ubuntu-trusty-64:~$ sudo cat /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

無題

Change permission

vagrant@vagrant-ubuntu-trusty-64:~$ sudo cp /etc/sudoers.d/vagrant /etc/sudoers.    d/student
vagrant@vagrant-ubuntu-trusty-64:~$ sudo nano /etc/sudoers.d/student
student@vagrant-ubuntu-trusty-64:~$ sudo ufw status
Status: inactive

play command line

vagrant@vagrant-ubuntu-trusty-64:/$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

All packages list below

vagrant@vagrant-ubuntu-trusty-64:/$ cat /etc/apt/sources.list

Update software

vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-get update

install

vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-get install finger

Apache HTTP Server apache2
PostgreSQL postgresql
Memcache memcached

type finger

vagrant@vagrant-ubuntu-trusty-64:~$ finger
Login     Name       Tty      Idle  Login Time   Office     Office Phone
vagrant              pts/0          Jan 18 12:14 (192.168.53.1)
vagrant@vagrant-ubuntu-trusty-64:~$ cat /etc/passwd

add user

vagrant@vagrant-ubuntu-trusty-64:~$ sudo adduser student
Adding user `student' ...
Adding new group `student' (1002) ...
Adding new user `student' (1002) with group `student' ...
Creating home directory `/home/student' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
Sorry, passwords do not match
passwd: Authentication token manipulation error
passwd: password unchanged
Try again? [y/N] y
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for student
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n]

sudo file

student@vagrant-ubuntu-trusty-64:~$ sudo cat /etc/passwd
[sudo] password for student:
student is not in the sudoers file.  This incident will be reported.

command line

vagrant@vagrant-ubuntu-trusty-64:~$ pwd
/home/vagrant

show hidden file

vagrant@vagrant-ubuntu-trusty-64:~$ ls -a
.  ..  .bash_logout  .bashrc  .cache  .profile  .ssh

ls -al long command

vagrant@vagrant-ubuntu-trusty-64:~$ ls -al
total 28
drwxr-xr-x 4 vagrant vagrant 4096 Jan 18 12:09 .
drwxr-xr-x 4 root    root    4096 Jan 18 12:08 ..
-rw-r--r-- 1 vagrant vagrant  220 Apr  9  2014 .bash_logout
-rw-r--r-- 1 vagrant vagrant 3637 Apr  9  2014 .bashrc
drwx------ 2 vagrant vagrant 4096 Jan 18 12:09 .cache
-rw-r--r-- 1 vagrant vagrant  675 Apr  9  2014 .profile
drwx------ 2 vagrant vagrant 4096 Jan 18 12:09 .ssh

All file in root directory

Linux

Ubuntu:Ease of use on servers, desktops, laptops
https://www.ubuntu.com/

CentOS
https://www.centos.org/

RedHat:Large enterprise / corporate customers
https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux

CoreOS
https://coreos.com/

getting started ubuntu
>vagrant init ubuntu/trusty64

then, start vagrant up command.
here comes


Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-105-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Wed Jan 18 12:13:23 UTC 2017

  System load:  0.09              Processes:           75
  Usage of /:   3.5% of 39.34GB   Users logged in:     0
  Memory usage: 26%               IP address for eth0: 10.0.2.15
  Swap usage:   0%                IP address for eth1: 192.168.53.10

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

New release '16.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.