- 博客(33)
- 资源 (1)
- 收藏
- 关注
原创 Ruby on Rails testing using rspec
Testing# Gemfilegroup :development, :test do gem 1 gem 2 gem 3endgroup :development do gem 4 gem 5 gem 6end# spec folder# rails_helper.rb# spec_helper.rb# model folder# name_spec.rb# features folder# names_spec.rb# in m
2020-11-15 02:10:06 164
原创 Java subtype, extension, and inheritance
InterfaceInterface separates the specification of an object from its implementationEach class is a subtype of any interfaces it implements.public interface Displaceable { public int getX (); public int getY (); public void move(int dx, int dy);}
2020-11-14 03:16:08 214
原创 Java ASM 简介
Java ASMFeatures of Java Abstract Stack MachinesWorkspacekeeps trach of expression or command that the computer is currently simplying.Stack: static memory allocation stored in RAM in a contiguous blockAlmost everything including variables stored
2020-11-14 01:25:00 209
原创 LaTex Citation And Footnote 引文和脚注
LaTex: Citation and FootnoteCreating a .bib fileUsing bibtex generator onlineInline citation \cite{label}.\bibliography{location&nameWithout.bib}\bibliographystyle{ieeeetr}Autogenerate footnotes\documentclass{article}\usepackage[backend=bibt
2020-11-14 00:09:00 1689
原创 Java Resizable Array Demo
Resizable ArraysInvariant0 <= extent <= buffer.lengthif extent = 0 then all of the elements of the ResArray are 0.if extent > 0 then buffer[extent - 1] is the last non-zero value in the ResArray.Interfacepublic class ResArray { privat
2020-11-14 00:04:04 125
原创 Core Java Basics
Java Interfacepublic interface Displaceable { public int getX (); public int getY (); public void move(int dx, int dy);}public class Point implements Displaceable { private int x, y; public Point(int x0, int y0) { x = x0; y = y0; }
2020-11-14 00:02:22 104
原创 Ruby Or Equal Operator: ||=
Conditional Assignment Operatora ||= nil # => nila ||= 0 # => 0a ||= 2 # => 0If a is undefined or false, the assign b to a, otherwise do nothing
2020-11-13 12:42:56 103
原创 Ruby on Rails: Nested Resources Demo
rails new nestedResourcesDemorails g scaffold User username:string passwrod_hash:stringrails g scaffold Post user:references title:string content:text# user.rbhas_many :post# post.rbbelongs_to :userrails db migraterails c@user = User.create
2020-11-13 12:38:43 116
原创 Ruby on Rails: Form and Authentication 表以及用户登陆与退出
FormThe destination urlWhether the data is associated with a modelThe field namesThe field input typesThe display name of fieldsWith URL:<%= form_with url: '/login' do |form| %> <%= form.label :email %> <%= form.
2020-11-13 12:37:07 150
原创 Rails server error: server is already running
server is already running.Solution: kill the serverkill -9 $(lsof -i tcp:3000 -t)
2020-11-11 22:38:58 285
原创 Ruby on Rails: database relations and common errors 数据库关系建立以及常见问题
One-to-many and Many-to-many relationshipsrails g scaffold Department code:string name:stringrails g scaffold Course department:references code:integer title:string description:textrails db:migraterails g scaffold User first_name:string last_name:st
2020-11-11 10:33:52 157
原创 Ruby: Scaffold Generator, AREL, Validation, One-to-many, Many-to-many
Scaffold GeneratorIt generates:Model/migrationcontoller file and implementationthe entire view folderall restful routesrails new blogDemonstrationcd blogDemonstration/rails g scaffold Post title:string content:textrails d scaffold Post# in
2020-10-26 05:49:34 140
原创 Ruby on Rails Blog Project 创建博客网站项目
Blog projectSet up projectrails new Blog --db=postgresqlcd Blograils s -b 0.0.0.0# localhost:3000Home Pageget '/pages', to: 'pages#home' in routes.rbCreate pages_controller.rb in controllers folderclass PagesController < ApplicationControl
2020-10-18 12:31:00 173
原创 Bootstrap v5 Button 带有图标的按键
Button IconFontawesome<!-- google fonts --><script src="https://kit.fontawesome.com/1d9373cc66.js" crossorigin="anonymous"></script><button type="button" class="btn btn-dark btn-lg"> <i class="fab fa-apple"></i>
2020-10-18 11:19:27 730
原创 Bootstrap v5 Grid Design and Container 布局设计
Grid Layout SystemTotal columns for single row is 12. col-6 is 50%.sm not specified will automatically to be col-sm-12<div class="container"> <section id="layout 1"> <div class="row"> <div class="col-lg-3 col-md-4 col-sm
2020-10-18 11:18:14 179
原创 Bootstrap v5 Navigation Bar 导航栏
Bootstrp 5CSS<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha2/css/bootstrap.min.css" integrity="sha384-DhY6onE6f3zzKbjUPRc2hOzGAdEf4/Dz+WJwBvEYL/lkkIsI3ihufq9hk9K4lVoK" crossorigin="anonymous">Navigation Bar
2020-10-18 11:17:31 731
原创 网站设计常用工具
Design toolsDesign ideas: Dribbble.com Design-pattern.comDesign: Balsamic.cloud Sneakpeekit.comFonts: Google fontsAdd fontgo to Google fontsAuto-generated:<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100&fami
2020-10-18 11:16:03 254 1
原创 Ruby: Arel and Forms
Data typesstringtextintegerfloatdecimaldatetimetimestamptimedatebooleanreferencesSQL -> ORM -> Arel# Common commandsUser.where(name: 'Simon')User.find_by(name: 'Simon')User.limit(2)User.order(id: :desc)# Chaining commandsPost.wh
2020-10-17 22:47:29 113
原创 Ruby: Rails basic structure creation and debugging Rails项目的编写与调试
RailsFundamental Rail Commands:rails new PROJECT_NAME # creat eall filesrails s -b 0.0.0.0 # boots up server, listen for request on port 3000Route -> Controller -> Viewdefine routeshandler methods in controllerwrite view templates in the
2020-10-11 02:48:25 132
原创 LaTexTableOfContent 编写LaTex目录
LaTex: Table of ContentUsing section heading to create table of content\tableofcontents\newpageList of figures and tables\begin{appendix} \listoffigures \listoftables\end{appendix}Set the depth of table of content by using\setcounter{tocdepth
2020-10-11 01:20:48 3701
原创 Ruby: Rails structure and naming convention Rails结构与命名规则
Content:LogicIntroductionConventionsRuby on Rails Logic*Browser* <--request/response--> *Server* --request_info--> *Routing* ^ | | Params + Methods | | HTML + Assets V
2020-10-10 23:03:38 139
原创 LaTex: Table And List 图表与列表
LaTex: Table and ListTable\documentclass{article}\begin{document}\begin{table}[h!] \begin{center} \caption{Your first table.} \label{tab:table1} \begin{tabular}{l|c|r} % <-- Alignments: 1st column left, 2nd middle and 3rd right, with
2020-10-04 02:51:51 314
原创 Network Layers 网络层介绍
Network4 networking layerslink layer: physical mediadirection connections between machinespacket-basedinternet layerwho do I want to talk to?Internet Protocol (IP) addressIPv4 (32-bit) and IPv6 (128-bit)how do I get messages to/from them
2020-10-04 02:49:39 349
原创 LaTex: Figures 插入图像
LaTex: FiguresImages in LaTex\documentclass{article}\usepackage{graphicx}\begin{document}\begin{figure} \includegraphics[width=\linewidth]{boat.jpg} \caption{A boat.} \label{fig:boat1}\end{figure}Figure \ref{fig:boat1} shows a boat.\end{
2020-10-04 02:48:11 1024
原创 LaTex: Math Symbols and Formula 数学符号与公式
LaTex: MathInline mathusing dollar signThis formula $f(x) = x^2$ is an example.Equation and Align EnvironmentAlign environemnt will align equations at &.Linebreaker is required.AlignAlign* provide line numbers\tag for inline explanation\docu
2020-09-25 08:08:57 695
原创 Unix Basic Command Line Unix 基础命令
Basic Command LineManipulate files foldersCommand line -> running a shele (bash, zsh…)Graphical interfacesclearls #print out contents of the current directoryls directoryls -l #long format: more information of contentspwd #print direct
2020-09-25 08:07:07 229
原创 Revision Control: Git 版本控制
Revision Controlgit version controlKeep track of change of codeCentralizedSubversion - svnDecentralizedRepository on central serverGit:Files can be:Untracked: outside gitStaged: add to git, only pushing cleaned neccessary changes.Unstaged
2020-09-25 08:05:56 152
原创 LaTex Introduction 基础介绍
LaTex: IntroSimple ExampleInstructions: “\commandname{option}”\documentclass{article}\begin{document} Hello World!\end{document}An environment is simply an area of your document where certain typesetting rules apply.Documentclass: article, book…
2020-09-20 23:24:38 1054
原创 Ruby: Object-Oriented-Programming 面向对象编程
OOPTable of contentsClass declarationInstance variables and methodsConstructor method initializeInstance variables and Instance MethodsReader/Writer methodsOther instance mtehodsClass variables and Class methodsPrivate methodsDescribing metho
2020-09-20 23:20:23 142
原创 Ruby: Basic Syntax 基础语法
Ruby BasicsRuby is strongly typed and dynamically typedirb # run in command lineibj = object.newobj.classobj.class.superclassobj.methodsfoo = 5# Print string# "#{var}"p "Hello, #{foo}!"# Orp 'Hello, ' + foo.to_s + '!'def obj:talk(message,
2020-09-20 21:55:26 142
原创 HTML&CSS Basics 网站构建基础
HTML<!DOCTYPE html><html> <head> <!--essential information--> <title> title </title> </head> <body style="background-color: purple"> <h1>Section 1</h1> <h2>Sec
2020-08-31 17:41:11 139
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人