摘要: 第一章 排序 1. 桶算法(简单): 缺点:太占空间,只能对数本身排序,无用。 C: int a[11], i,j,t; for (i= 0;i <= 0; i++){ ... } ruby: For ... In 本质上for...in是语法糖,ruby translates it into sh 阅读全文
posted @ 2018-01-08 20:22 Mr-chen 阅读(328) 评论(0) 推荐(1) 编辑
摘要: 周六加班,停。周日上午复习SQL语法。 什么是档案? 所有正在执行中的程序和数据,都是放在内存(memory)之中。内存存取速度快,但是容量小而且一关机数据就不见了。 档案则是存在硬盘上,容量大但存取慢,但是关机重来还是继续保存着。 所谓的读取档案就是将数据从硬盘放进内存里面,让程序可以操作。反之写 阅读全文
posted @ 2018-01-07 16:40 Mr-chen 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Object 也是一种数据类型,可以有属性,有method. 反之,在Ruby中,每一种数据类型都是Object。如String,Integer,Float,Array,Hash. IN Ruby everything is a object! http://chentianwei-blog.log 阅读全文
posted @ 2018-01-05 09:35 Mr-chen 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 早上git加星了webapp的教程 > h = Hash.new('Go Fishing') => {} // 创建一个空hash,设定"Go Fishing"为默认的值。 > h['c'] => "Go Fishing" > h => {} //但并没有存入hash。仍然是空的。 创建一个空has 阅读全文
posted @ 2018-01-04 09:58 Mr-chen 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 运行clone的.rb档案。用ruby name.rb 1.输入,处理,输出。 print "请输入你的\"名字\",然后按 Enter: " your_name = gets puts "hi,#{your_name}" 解释: print 输出变量在荧屏,不会换行 puts 输出变量但会换行。 阅读全文
posted @ 2018-01-01 11:32 Mr-chen 阅读(196) 评论(0) 推荐(0) 编辑
摘要: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store 两个相连的表格 Manufactures: code, name products: code, name, price, manufacturer //黄色是关联。 15. 阅读全文
posted @ 2017-12-31 16:37 Mr-chen 阅读(255) 评论(0) 推荐(0) 编辑
摘要: Udacity: Intro to Relational Databases The syntax of the select statement with a where clause: select columns from tables where condition ; keyword + 阅读全文
posted @ 2017-12-27 11:29 Mr-chen 阅读(202) 评论(0) 推荐(0) 编辑
摘要: SQL 基础学习(2) Joining 可以同时关联(joining)多张表进行复杂的查询。 相比于用Rails捞出数据再用Ruby进行过滤组合,使用SQL更加高效,节能。 以下是 users has_many events的情景,打开DB Browser for SQLite 并新建一个文件dem 阅读全文
posted @ 2017-12-26 09:36 Mr-chen 阅读(291) 评论(0) 推荐(0) 编辑
摘要: Update_columns(attributes) //等同于update_column 直接更新database. 使用UPdate SQL 语法。 ⚠️ :忽略了validations, Callbacks. 所以速度最快。但不能更新只读属性,或called on new objects. 完 阅读全文
posted @ 2017-12-22 10:26 Mr-chen 阅读(200) 评论(0) 推荐(0) 编辑
摘要: destroy_all and delete_all Destroy the records by instantiating each record and calling its #destroy method.在删除前实例化每条记录,并回调callback execution. ⚠️ :如果想 阅读全文
posted @ 2017-12-21 09:09 Mr-chen 阅读(292) 评论(0) 推荐(0) 编辑