How to upload files to a web server FTP SSH

A reminder for the fastest way to upload files to a web server. First, archive (.zip) the files you need to upload. Upload the .zip archive. Using SSH unzip the files into the correct directory. You can also archive using .TAR if you are using Linux. You’ll also want to make sure your server or host has unzip. If not, you can download the linux unzip binary utility here and then upload it to your home directory.

The reason this is faster is because when uploading a large number of files FTP uses HTTP which is a reliable method for transferring data. Each file that has to be sent to the server requires many communication requests and acknowledgments to make sure ALL the data is arriving at its destination correctly. This essentially requires a lot of communication, especially when you are uploaded a large number of files! This is something to remember when uploading software like WordPress or Code Igniter, which has literally thousands or files in each package. Sometimes it will take 15 minutes to upload WordPress. However, if you .Zip the file, you are only transferring one file, which requires less communication, and is essentially faster. :)

Dreamhost and Code Igniter 404 Model not found

I was having errors when I moved my Code Igniter application from my Windows XP XAMPP development box to a Linux apache server. I was getting 404 errors and Model Not Found errors.

This was related to two problems. First, the 404 has to do with the .htaccess file. I was using the mod_rewrite to remove the index.php from the URL. You can find solutions on the Code Ignite / Dreamhost wiki page. I used solution 1.

Secondly, I mentioned that I was doing my development on a local Windows XP machine using XAMPP (Windows Apache MySQL PHP). Since Windows uses more “flexible” file naming conventions, the reason my Models weren’t being found was that the naming schemes were wrong.

Models should be name ‘Name_model.php’. When you load a Model in your Controller you need to load it use $this->load->model(‘manufacturer_model.php’,”,TRUE);

You need to remember this when loading files and classes. Check your controllers, and rename your models! :) Have fun, and remember use Dreamhost for all your web hosting needs. They are the best (for real)!

Batch Script GIMP Auto White Balance Auto Levels

If you have a large folder of files you want to perform an action on using GIMP, the correct way to do this is using Script-Fu plugin. I’m going to tell you some things to make this a lot easier. At the end I will show you the code I used to batch process (Auto Levels/Auto White Balance). Also, I’m going to explain the script in depth, so you can modify it for your own needs!

First, you need to use Linux. I recommended Ubuntu 10.10 which I am using. I have also done this with Ubuntu 9.10. Simply put, you need a BASH shell, which Windows doesn’t have. NOTE: there might be a way to do this using the Windows command line, however, I am not familiar with the syntax, and couldn’t find anything quickly about it online, sorry :(

Install GIMP on your machine. You’ll need the script below. Save it as a .SCM file in /home/yourusername/.gimp-2.x/scripts. NOTE you need to run GIMP at least once first before this folder will appear in your home directory. Here is the script. (define (batch-levels-stretch pattern)
(let* ((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let* ((filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE
filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(gimp-levels-stretch drawable)
(gimp-file-save RUN-NONINTERACTIVE
image drawable filename filename)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))

Next, navigate to the folder where your images are. Run this command in the terminal gimp -i -b '(batch-levels-stretch "*.jpg")' -b '(gimp-quit 0)'. This applies only for the script above.

Next, to make your own script. Here are the things you need to know.
1. Open GIMP, FILTERS > SCRIPT-FU > CONSOLE > BROWSE. now you can search for all the commands you will need. This documentation will tell you the parameters for each command, and more very important information. This console is essential for any one writing their own script.
2. let’s look at pieces of the script itself:
(define (batch-levels-stretch pattern)this defines the name of your script and the parameters it takes.
(let* ((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let* ((filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE
filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
For Basic Batch mode processing, IGNORE this! it essentially defines some variables about the file name, image properties, etc. don’t worry about this code. it can be found on the Gimp Basic Batch tutorial page. This code opens the images and prepares it for the commands we want to run.
(gimp-levels-stretch drawable)
This is the Auto Levels/Auto White Balance command. It takes a drawable as a parameter. Easy. Done.
(gimp-file-save RUN-NONINTERACTIVE
image drawable filename filename)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))

Now, let’s save the file and move on to the next image. Done and Done.

3. If you want to use another command other than “gimp-levels-stretch”. Go to the Script-fu console, determine the parameters, and modify the above. The link above is helpful. You might want to use the code on that webpage as a starting point. The first line is important, and the line where you execute your commands. now you can have your cake and eat it too. sorry if this tutorial was insulting. simply, i didn’t find any other material on the web like this, so i figured i’d put it on my blog to help some noob programmers get their batch mode goin’. thanks for the link to my site ;)

敬香茶

敬香茶

宋代大文学家苏东坡,常常一个人出去旅行。他特别喜欢参观寺庙。有一天,他走进座寺庙。庙里的老和尚看了看进来的这个人,觉得他好像是教小孩的老师,是一个很普通的人,就坐着没动,只说一个字,“坐。”他又指了指小桌子上的茶壶,说:“茶。”

苏东坡笑了笑,就坐在小桌旁边。他小声地问了老和尚一些问题,老和尚发现这位先生知道的东西很多,就站起来热情地说:”请坐!”又对小和尚说,”敬茶!”

老和尚问苏东坡:”请问,您贵姓?”苏东坡说出了自已的名字。老和尚没想到,这位先生就是大文学家苏东坡,他马上把苏东坡请到大桌子前边,很客气地说:”请上座!”而且还大声地对小和尚说:”快!快!敬杳茶”苏东坡笑着说:”不客气!”

老和尚知道,苏东坡不但是一位大文学家,而旦还是一位大书法家。他想,如果请苏东坡给寺庙写一幅字,他们的寺庙就会更有名,这是一件大好事儿。想到这儿,他马上去房子里拿出大张纸来,把它放在桌车上,再把两手放到胸前,嘴里说:”阿弥陀佛!阿弥陀佛!我想请您绐我们写一幅字。”

苏东坡站起来,想了想,说:”可以。”他就把老和尚刚才说的话写在纸上:
“坐,请坐,请上坐。
茶,敬茶,敬香茶。”
老和尚站在旁一边看,一边念。念完这十二个字,他的脸红了。

wish there was a way

to integrate all the social services i use into one, single to use, easy, desktop application. wow, what a concept!

Friends in XinDu

Boring night in XinDu during the Spring Festival so I decided to go to Dico’s (德克士) to get some food. I met these guys at the restaurant.

春节的时候,在新都区德克士有第一次认识朋友们。他们都是老师呵呵

Blog is getting old

I should be posting daily about my studies in China… Sorry guys! I hope you’re ready to learn some Chinese…..

Add Categories to WordPress K2 Menu

This is a simple hack to enable you to place your ‘Categories’ on the menu of the K2 WordPress theme (or any other theme). Fortunately, the WordPress API has a function for displaying the categories. This will make it easy for us.

Using K2, open /wp-content/themes/k2/blocks/k2-header.php. Find the <?php “wp_list_pages( ); ?> code. Underneath this, you will want to put your code. Read this page here for the full list of options. This is what I use

<?php
//List categories
wp_list_categories(‘orderby=name&include=3,16,17&title_li=’);
?>

If you aren’t using K2, you will need to find the file that displays the menu. The best place to start is in the root of your theme (/wp-content/themes/your-theme/header.php) and look for a function wp_list_pages( ); that will probably be near the <body> html tag. It might not be in the header.php file, and another good place to look is in the root/blocks folder.

Rodney Mullen 1983

Inspiring skate video, http://v.youku.com/v_show/id_XOTg3NDcxMjg=.html

“Most people look at a champion and say, ‘Oh, what a great life” but really, it’s a lot of work. The hard part, even harder than getting to be number one, is staying there. Being there and staying there. That’s when the real stamina and real professionalism comes out in a person. That’s when it gets tough.”

让你受益一生的18条求职定律

转载自 明子阳    转载于2010年02月14日

  1.一定要有独立的人格、独立的思想。
  一个经过独立思考而坚持错误观点的人比一个不假思索而接受正确观点的人更值得肯定。不要成为灌输教育的牺牲品。
  2.仕途,商界,学术。大致说来,每个人都注定要走上三条道路中的某一条。
  在进行职业生涯规划的时候,不妨以此作为思考的出发点。根据不同的职业生涯规划来塑造各自的核心竞争力。只有知道自己以后要做什么,才能知道自己应该学什么。
  3.专业无冷热,学校无高低。
  没有哪个用人单位会认为你代表了你的学校或者你的专业。千万不要因为你是名牌大学或者热门专业而沾沾自喜,也大可不必因为你的学校不好或者专业冷门而自卑。
  4.千招会,不如一招熟。
  十个百分之十并不是百分之百,而是零。如果你有十项工作每项都会做百分之十,那么,在用人单位眼中,你什么都不会。所以,你必须要让自己具备核心竞争力。“通才”只有在“专才”的基础上才有意义。
  5.不逃课的学生不是好学生。
  什么课都不逃,跟什么课都逃掉没什么两样。一定要掌握学习的主动性,不要像读中学一样被老师牵着鼻子走。逃课没有错,但是不要逃错课。同时,既要逃课,又要让老师给高分。
  6.一定要学会理财。
  对于贫困生来说,首先要做的不是挣钱,而是省钱。很多大学生读书的时候一掷千金,可是,毕业以后一个月的工资还不够交半个月的房租。
  7.大部分女生将电脑当成了影碟机,大部分男生将电脑当成了游戏机。
  大学生要掌握必要的计算机操作能力,但是,很多时候电脑会成为浪费时间的堂而皇之的借口。有电脑的大学生非常多,可是,这中间很多人可能大学毕业的时候还不会Excel,不会做一个像样的PPT。
  8.做事不如做人,人脉决定成败。
  一个人有多少钱并不是指他拥有多少钱的所有权,而是指他拥有多少钱的使用权。一个人具备多少能力,不只是说他一个人的时候能做什
  么,还包括他能通过别人做什么。一个人赚的钱,12.5%是靠自身的知识,87.5%则来自人脉关系。三十岁以前靠专业赚钱,三十岁以后拿人脉赚钱。所以,请好好珍惜大学期间建立起来的人脉关系。这几年你认识的朋友可能会是你毕业以后最可宝贵的财富。
  9.互联网固然威力无穷,但是,如果你沉迷于网络聊天,或者沉迷于网络游戏,浪费的金钱倒是可以弥补,荒废的青春就无可追寻了。对于很多大学生而言,网吧就是一个血淋淋的黑洞。
  10.爱情是不期而至的,可以期待,但不可以制造。花开堪折方须折,莫让鲜花败残枝。
  一个有一万块钱的人为你花掉一百元,你只占了他的百分之一;而一个只有十块钱的人为你花掉十块,你就成了他的全部。
  11.研究生扩招的速度是30%,也就意味着硕士学历贬值的速度是30%。
  千万不要以为考研究生就是积极进取的表现。对于很多人而言,考研不过是一种消极逃避的方式罢了。对于绝大多数人而言,读研究生纯粹是浪费时间浪费金钱,立志从事科研、学术的人及其他少数人除外。
  12.不要一门心思想着出国,更加不要迷信外国的月亮比中国圆。
  削尖脑袋记GRE词汇很可能是一件非常愚蠢也非常可悲的事情。既然全世界的公司都想到中国的市场上来瓜分蛋糕,为什么中国人还要一门心思到国外去留学然后给外国人打工?
  13.人才市场就是一个地雷阵。
  通过多种方式求职固然没有错,但是千万不要饥不择食。只要用人单位一说要你交钱,你掉头就走便是了。
  14.求职简历必须突出自己的核心竞争力。
  求职的时候大可不必像严守一那样“有一说一”,必要的时候恰到好处地说一些谎言是非常有用的。一份求职简历只要用一张A4纸做个表格就足够了。很多女生的求职简历就像是**集,不但浪费钱,而且对求职毫无用处。面试其实是有规律的,每次面试的时候只要背标准答案就行了……
  15.垃圾是放错位置的人才。
  所以,在找工作的时候一定要把自己放到那个让你成为人才而不是垃圾的职位上。当然,前提是你要知道自己究竟想做什么、究竟适合做什么。
  16.大公司是做人,小公司是做事。
  进入公司工作以后,必须尽快融入写字楼政治。职员能否得到提升,很大程度不在于是否努力,而在于老板对你的赏识程度,在写字楼的****中,一定要学会自我保护。
  17.瘦死的骆驼比马大。撑死胆大的,饿死胆小的。
  一定要有创业的勇气和魄力。如果你一直满足于给别人打工,那么,不管你工资多高,永远都只能是一个可怜的穷光蛋。就算**2万,在深圳上海那种地方,一年的存款还买不来一个小小的洗手间。
  18.大学期间一定要多去图书馆多去自习室。
  很多书你现在不读,一辈子就再也没有机会去读了。虽然不是每本书看了都一定有用,但是,因为你不知道究竟哪本书以后会有用,所以只好多看书,并且抛弃那些过于功利的想法。尽管每次网到鱼的不过是一个网眼,但要想捕到鱼,就必须要编织一张网。