PigRider Blogs

Sign In
HTML CSS Javascript Ruby on Rails C++ Java Python SQL Git Linux Others All
Previous 1 2 3 4 5 6 7 8 Next

Basic Object-Oriented Programming Concepts

[Author: Dingyu]   [Tue, 2013-08-20, 13:05]   [1363 views]

Others

Basic Object-Oriented Programming Concepts
Class vs. Object
Many people get confused by the difference between class and object. The difference is simple and conceptual. A class is a template for objects. A class defines object properties including a valid range of values, and a default value. A cla ... see full article

Use database.yml to Set Multiple Databases in a Rails Application

[Author: Dingyu]   [Sun, 2013-08-18, 15:01]   [1248 views]

Ruby on Rails

In the database.yml, the code looks like:
# MySQL.  Versions 4.1 and 5.0 are recommended.
# 
# Install the MYSQL driver
#   gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
#   gem 'mysql2'
#
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5 ... see full article

Basic Multithreading Concepts

[Author: Dingyu]   [Thu, 2013-08-15, 14:46]   [1392 views]

Others

Basic Multithreading Concepts
Concurrency and Parallelism
In a multithreaded process on a single processor, the processor can switch execution resources between threads, resulting in concurrent execution. Concurrency indicates that more than one thread is making progress, but the threads are not act ... see full article

Python glob module

[Author: ming.lian]   [Wed, 2013-08-14, 20:16]   [1463 views]

Python

Python glob is for finding the pathnames matching the pathname pattern accroding to the rules used by the Unix shell.
if you want to grab all the .txt files under C drive, you can do this:
import glob
list = glob.glob(r'c:/*.txt')
print list
and it will return a list that contains all the txt files. ... see full article

Print Beautiful JSON with Python

[Author: ming.lian]   [Mon, 2013-08-12, 20:42]   [1738 views]

Python

>>> import json
>>> print(json.dumps(data))  # No indention
{"status": "OK", "count": 2, "results": [{"age": 27, "name": "Oz", "lactose_intolerant": true}, {"age": 29, "name": "Joe", "lactose_intolerant": false}]}
>>> print(json.dumps(data, indent=2))  # With indention
{
  "status": "OK",
  "count" ... see full article

MySql: add auto-increment feature to a column in Ruby on Rails

[Author: ming.lian]   [Sun, 2013-08-11, 17:47]   [3184 views]

Ruby on Rails SQL

In ruby on rails, if you need to set a column with auto-increment, you have to execute a SQL command in your model.
Alter table Tablename modify column ColumnName int(11) auto_increment; ... see full article

Create MySQL composite primary key in Ruby On Rails

[Author: ming.lian]   [Sun, 2013-08-11, 17:47]   [2086 views]

Ruby on Rails SQL

MySql默认是以primary key作为clustered index,如果没有primary key的话,就以第一个unique index column作为clustered index,不需要单独建clustered index。
但是Ruby on Rails默认以自动生成的id作为primary key。所以如果你不想用自动生成的id作为primary key,则需要在ruby on rails里手动声明primary key。
代码如下:
create_table :table_name, :id => false do |t|
  t.integer :column_1 ... see full article

Common Git Commands

[Author: ming.lian]   [Sun, 2013-08-11, 17:46]   [1728 views]

Git

新建项目流程 选择generate my own code
#git init
#git remote add origin username@pigrider.com:/GitRepository/pigRiderDev/pigRiderTools.git
#git fetch
#git branch --track master origin/master
#git checkout master
或者用  git checkout --track -b master origin/master 来代替上面两条命令
初始化git
#git init
把master的主干pull到本地
#g ... see full article

Change the password in MySQL when you don't have SUPER privilege

[Author: Dingyu]   [Sun, 2013-08-11, 17:46]   [1319 views]

SQL

If you wish to change your password by yourself but you don't have the SUPER privilege, below process may help you.
Suppose that:
Your MySQL username is Nickname
Your current MySQL password is OldPassword
You wish to change your password to NewPassword 
1. Log into the MySQL
If you are logging into ... see full article

Python File Process Common methods

[Author: ming.lian]   [Sun, 2013-08-11, 17:44]   [1655 views]

Python

Open a file:
f = open('filename', 'r')
'r' means read only and if it is 'w', it means write only.
'rb' -> read binary
'wb' -> write binary
'w+' write append
f.write("I am an engineer.")
f.write(str) -> write a string.
f.writeline()
f.read() -> read all.
f.read(size) -> the size is the count that how ... see full article
Previous 1 2 3 4 5 6 7 8 Next

Recent Most Popular Blogs: