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

Python File Process Common methods

[Author: ming.lian]   [Sun, 2013-08-11, 17:44]   [1792 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

Find records with non-printable characters in T-SQL

[Author: Dingyu]   [Sun, 2013-08-11, 17:44]   [2437 views]

SQL

I know two ways to find records with non-printable characters in T-SQL. The first way, use the "like" statement to do it:
SELECT * FROM tableName
WHERE (columnName COLLATE Latin1_General_BIN2) like '%[^' + CHAR(32) + '-' + CHAR(126) + CHAR(9) + CHAR(10) + CHAR(13) + ']%'
The second way, use the "PAT ... see full article

Install Python Module

[Author: xiaotian.li]   [Sun, 2013-08-11, 17:43]   [1915 views]

Python

Here I'm going to introduce 2 ways of installing python module for import.
1. Using easy_install
    Easy Install is a python module (easy_install) bundled with setuptools that lets you automatically download, build, install, and manage Python packages.
Step 1:
Add path to system variables.
Go to "C ... see full article

Install PyDev in Eclipse

[Author: xiaotian.li]   [Sun, 2013-08-11, 17:43]   [2287 views]

Python

First, make sure you have downloaded an appropriate Python version from http://www.python.org/download/
Next are the instructions targeted at Eclipse 3.5 onwards.
1. To install PyDev and PyDev Extensions using the Eclipse Update Manager, 
Go to: Help > Install New Software... menu.
2. In the next sc ... see full article

How to Set Primary Keys Other Than :id in Rails 3 with MySQL

[Author: Dingyu]   [Sun, 2013-08-11, 17:43]   [3769 views]

Ruby on Rails SQL

In Rails 3, the primary key in a database table is very important. Rails model ActiveRecord functions, like save, destroy, update_attributes, and so on, require it to invoke callbacks. Rails 3 uses the column 'id' as a default primary key in a database table. However, in MySQL, only the primary key ... see full article

What is attr_accessor in Ruby?

[Author: Dingyu]   [Sun, 2013-08-11, 17:43]   [1230 views]

Ruby on Rails

I copied this article from a Stockflow post. Click here to see the original Stockflow post.
Let's say you have a class Person.
class Person
end
person = Person.new
person.name      # no method error
Obviously we never defined method name. Let's do that.
class Person
  def name
    @name      # simpl ... see full article
Previous 1 2 3 4 5 6 7 8 Next

Recent Most Popular Blogs: