Archive

Posts Tagged ‘Tutorial’

Reading number from file in Python

December 10th, 2009 Fu4ny No comments

Err, that was  a long time since my last tutorial. I'm learning Python now, and I decided to write some tutorials for it.

As you know, there's a simple concept about Python: "You have plenty of way to do things". This is, sometime, a advantages, but sometimes it's hard to decide the way you do "your things".

Today, I'll show you some ways to read number from file input, The good, the bad, and the ugly

The good, tradition, easy:

1
2
3
4
5
6
fin = open("input.txt","r")
for line in fin.readlines():
   #unpack with line.split()
   p = line.split()
   #Get your variable
   n = int(p[0])

Why it's good: it's easy to understand, easy to maintain, easy to write (but slow as hell ).

It's just do the job: read line one by one, split and pack number in to a tuple

The bad, tradition, and still works

1
2
3
4
5
fin = open("input.txt","r")
t = fin.read()
inputTuple = t.split()
for i in inputTuple:
    print i

Thingy: it's just read all the file, split and store all the number into a tuple, whenever you want them or not. It's just eating you RAM, *yum yum*

The ugly, if you want one-liner

1
[i for x in [x.split() for x in open('input.txt')] for i in x]

It's just very good, do all the thing in "The bad" ways, but with only one-line. Do it if you don't want anyone to understand your code.

The IDK, if you just want to read 1 number

1
2
3
4
fin = open("input.txt",'r')
n = ''
while ( n[-1] != ' ' ): n += fin.read(1)
n = int(n[:-1])

Another, just works, easy to understand code.

Is there any other ways that you know ;)

Categories: Post Tags: , ,

TextLinkAds – Insight to InLinks

November 17th, 2008 Fu4ny 1 comment

I registered in Text-link-ads for so long, and still do not gain any money.

But recently text-link-ads release InLinks,  and my blog started gaining money, it's not much, but 30$ each month is a nice profit.

But is InLinks that good ? Let take a look closer.

How it works ? You will install a InLinks plugin on your blog, and it'll send your blog post to TLA. People (called Advertiser) will buy link on your post.

But why must they buy your link? It'll increase their Inlink, which are use for SEO. If you want to know more about it, read some document about BackRub (now PageRank), Inlink are used by most search engine.

Is there any risk? Yes, there're alot. Google, Yahoo and many search engine will punish you. Sell link for inlink is forbidden, so if they found you do it, your rank will be lost. I heard alot of people say that their pagerank fall to 0 suddenly when they use InLinks.

Should I use it? Yes and no, if you want to make money, use it. Inlinks are easy to register, easy to config and make money without doing any works. But if you worry about your pagerank, don't use it.

At last, InLinks is a high risk way, Adventiser buy your link -> You pagerank will fall to 0 -> They will cancel your link and buy link in a high ranked blog -> and then that blog's rank fall -> they will start to find a new one.

I'm worring now, but 30$ each month is a good deal, why not forget about google's pagerank =))

Categories: Post Tags: , ,

Fu4ny@13/11

November 13th, 2008 Fu4ny No comments

Lâu lắm ko làm 1 cái advance tutorial, hôm nay rỗi ngồi viết cái vậy.

Comming soon: Add comment kiểu mới vào blog Wordpress

Categories: Post Tags: , ,

C++ Coding Convetion

November 4th, 2008 Fu4ny 2 comments

Bài viết này sẽ nói về quy tắc viết mã nguồn dành cho C++. Mình ko định làm nó thành 1 guide chuẩn, vì vậy ko cần thiết phải theo quy tắc, hay table of content gì cả... Read more...

[Tut]File name và IDM

March 11th, 2008 Fu4ny No comments

Chắc nhiều bạn dùng IDM cũng đã từng gặp tình trạng tải file ở các trang hide link bị hiển thị file name là "akghsdbg" ví dụ như link này http://cdn.livevideo.com/video/flash8/82/110382/31/329631.flv

File name IDM sẽ nhận là 329631.flv. Tình trạng này thường xuyên xảy ra khi down film bộ trên youtube hoặc clip.vn. Nếu chỉ có khoảng chục link thì ta có thể add URL và đổi tên ngay trong IDM được, nhưng neus là 1 bộ phim khoảng 50 phần thì sao nhỉ ???.

Read more...

Categories: Post Tags: , ,

Giáo trình tin học cơ sở

November 16th, 2007 Fu4ny 1 comment

Giáo trình Tin học cơ sở của mấy thầy trường tui. Bản full thì cả đĩa CD cơ. Nhưng có người request nên post bản thu gọn này. Bao gồm các file Power Point của phần Thực hành và lý thuyết.
Download : Giáo trình Tin học cơ sở 1, bản thu gọn các file PPt
Read more...

Categories: Post Tags: ,

Ngày 22/07

July 22nd, 2007 Fu4ny No comments

Cái list việc cần làm nó đầy lắm rồi, phải điểm lại mà hoàn thành thôi

  1. Tutorial CheatEngine theo yêu cầu 1 số người bên GVN
  2. Bài viết về VPN cho báo Echip, hứa với anh Chương mãi :D
  3. Bài viết về Localize flash nói chung cho anh JuneBoy
  4. Nốt cái bài về Wordpress.
  5. Nhiều việc quan trong khác =.=
  6. Tỏ tình :">
Categories: Post Tags: , , ,

01/06 – Kết thúc kì thi

June 1st, 2007 Fu4ny No comments

Please Login or Register to read the rest of this content.

Read more...

Categories: Post Tags: , , ,

Akismet – Fighting against Spam

March 14th, 2007 Fu4ny 3 comments

Khi blog của bạn hơi được chú ý một chút, cũng là lúc nạn spam bắt đầu xuất hiện và hoành hành, spam có thể chỉ là một vài người ác ý vào viết vài bài lằng nhằng, nhưng cũng có thể là những con spider từ những trang bán thuốc bổ thận, kẹo cao su ;)) ... Bạn có thể nói : Tự mình xoá, nhưng khi mà spam vài chục bài đến vài trăm bài 1 ngày thì bạn sẽ thấy nản.

Vậy sao ko cài một trình chống spam bên ngoài, hay điển hình là Akismet, một plugin đã được tích hợp sẵn vào Wp như là một plugin không thể thiếu.

Read more...

Đôi điều về Tags và Categories

March 13th, 2007 Fu4ny 3 comments

Tags và Categories là 2 khái niệm khá phổ biến trong Blogging, nhưng để phân biệt 2 khái niệm này thì còn nhiều người lầm tưởng.

Tags và Categories về bản chất là như nhau, nhưng về sử dụng thì có hơi khác nhau một chút xíu, tui nghĩ cũng sẽ có nhiều người tưởng nó như nhau, nên viết thêm 1 bài này, coi như 1 misc trong phần Big tutorial về wordpress

Q&A : Tags & Categories

Q : Vậy Tags và Categories là gì ?

Read more...

Categories: Post Tags: , , ,