Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!
Installing OpenVPN in rockmeweb.net Hosted VPS [Ubuntu or Debian]
VPS has been around for quiet sometime, and, If only I knew it earlier, I wouldn’t gave justhost.com people my money this year for their crappy server
.
Anyways, I got myself a VPS a week ago. before I decided to get one, I was actually seeking for a VPN provider. and when I googled, the term VPS keeps coming on to my screen….so I decided to give it a click…then I got a VPS from rockmyweb.net, nice speed, nice configuration, and cheap.
There are a lot of people talks about setup a VPN in VPS, but those threads are soooo long…after 2 days, I found this http://vpsnoc.com/blog/how-to-install-openvpn-on-a-debianubuntu-vps-instantly/.
This is quick and dirty. and there are a few things I need to modify here for rockmyweb.net hosted VPS, and I use ubuntu for my OS.
Requirement:
A VPS
NAT is enable on your server
Able to create tun nod
This script gives you one cert for you to connect to VPN, for multiple user, see openvpn docs. it’s just a matter of running ./build-key
make sure you have /dev/net/tun
normally you don’t, so you need to create one with root privilege.
mknod /dev/net/tun c 10 200
and you can make sure you have nat support
root@znxf:~# iptables -t nat -L
This usually gives you an empty list, but we know that nat is working(support staff says otherwise, but well, it’s working).
If you see a error message instead, you’ll need to contact support.
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
After you ran this script, you should have keys.tgz in your root folder. Move it to your ftp and download it to your computer, or scp it or whatever.
#!/bin/bash
#
# CrUmp crumpz.info
# Modified for rockmyweb.net hosted VPS
# 04/30/2011
#
# Quick and dirty OpenVPN install script
# Tested on debian 5.0 32bit, openvz minimal debian OS template
# and Ubuntu 9.04 32 bit minimal, should work on 64bit images as well
# Please submit feedback and questions at support@vpsnoc.com
# John Malkowski vpsnoc.com 01/18/2010
#
#
ip=`grep address /etc/network/interfaces | grep -v 127.0.0.1 | awk '{print $2}'`
dnss=`cat /etc/resolv.conf |grep [0-9] | awk '{print $2}'`
dns1=`echo $dnss | awk '{print $1}'`
dns2=`echo $dnss | awk '{print $2}'`
apt-get update
apt-get install openvpn libssl-dev openssl
cd /etc/openvpn/
cp -R /usr/share/doc/openvpn/examples/easy-rsa/ /etc/openvpn/
cd /etc/openvpn/easy-rsa/2.0/
chmod +rwx *
. ./vars
./clean-all
source ./vars
echo -e "\n\n\n\n\n\n\n" | ./build-ca
clear
echo "####################################"
echo "Feel free to accept default values"
echo "Wouldn't recommend setting a password here"
echo "Then you'd have to type in the password each time openVPN starts/restarts"
echo "####################################"
./build-key-server server
./build-dh
cp keys/{ca.crt,ca.key,server.crt,server.key,dh1024.pem} /etc/openvpn/
clear
echo "####################################"
echo "Feel free to accept default values"
echo "This is your client key, you may set a password here but it's not required"
echo "####################################"
./build-key client1
cd keys/
client="
client
remote $ip 1194
dev tun
comp-lzo
ca ca.crt
cert client1.crt
key client1.key
route-delay 2
route-method exe
redirect-gateway def1
verb 3"
echo "$client" > $HOSTNAME.ovpn
tar czf keys.tgz ca.crt ca.key client1.crt client1.csr client1.key $HOSTNAME.ovpn
mv keys.tgz /root
opvpn="
dev tun
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
ca ca.crt
cert server.crt
key server.key
dh dh1024.pem
push "route 10.8.0.0 255.255.255.0"
push "redirect-gateway"
push "dhcp-option DNS $dns1"
push "dhcp-option DNS $dns2"
comp-lzo
keepalive 10 60
ping-timer-rem
persist-tun
persist-key
group daemon
daemon"
echo "$opvpn" > /etc/openvpn/openvpn.conf
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o venet0 -j SNAT --to $ip
echo "#!/bin/sh" > /etc/network/if-up.d/iptables
echo "iptables-restore < /etc/iptables.conf" >> /etc/network/if-up.d/iptables
chmod +x /etc/network/if-up.d/iptables
sysctl -w net.ipv4.ip_forward=1
/etc/init.d/openvpn start
clear
echo "OpenVPN has been installed
Download /root/keys.tgz using winscp or other sftp/scp client such as filezilla
Create a directory named vpn at C:Program FilesOpenVPNconfig and untar the content of keys.tgz there
Start openvpn-gui, right click the tray icon go to vpn and click connect
For support/bug reports email us at support@vpsnoc.com"
Now you can download the keys and unpack it to use with Tunnelblick(Mac), or other VPN clients.
The C Programming Language Chapter 1 Exercise 1-16
好吧,这个说的是要把之前说到的主程序的 main function 部分修改一下,使它可以正确计算输入的字符个数,虽然它定下了 1000个字符的限制,通过修改 main() 的部分,超过一千字的,只计算字符个数而不打印超出的部分。
要求: Revise the main routine of the longest-line program so it will correctly print the length of arbitrarily long input lines, and as much as possible of the text.
这里有标准答案(话说,标准答案都很啰嗦啊。。。。),以下是自己写的。。。
#include
#define MAXLINE 10
int getline (char line[], int maxline);
void copy(char to[], char from[]);
int getline(char s[], int lim)
{
int c, i;
for(i = 0; i < lim-1 && (c=getchar())!=EOF && c!='n'; ++i)
s[i] = c;
if(c=='n')
{
s[i]=c;
++i;
}
s[i] = ' ';
return i;
}
void copy(char to[], char from[])
{
int i;
i=0;
while ((to[i] = from[i]) != ' ')
++i;
}
int main (int argc, char const *argv[])
{
int len;
int max;
char line[MAXLINE];
char longest[MAXLINE];
int c;
max = 0;
while ((len = getline(line, MAXLINE)) > 0){
if(line[len-1] != 'n'){
while((c = getchar())!='n')
++len;
}
if(len>max)
{
max = len;
copy(longest, line);
}
}
if(max > 0)
printf("nnLongest line has %d characters.nIt's:n%sn[... %d more chars are not printed]n(Newline and "\0" are counted)nn", max, longest,max-MAXLINE);
return 0;
}
The C Programming Language Chapter 1 Exercise 1-13
这个是昨天写的,这是这本书第一个比较正经的,需要思考一下的练习
要求: Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging.
这里有标准答案,我自己写了一个,如下。
#include
#define ARRAY_SLOTS 12
int main (int argc, char const *argv[])
{
int stars, counter, c, wc;
int wordTable[ARRAY_SLOTS];
stars=wc=counter=0;
for(counter = 0; counter < ARRAY_SLOTS; ++counter)
{
wordTable[counter] = 0;
}
while ((c = getchar()) != EOF)
{
wc++;
if(c == ' ' || c == 't' || c == 'n')
{
--wc;
if(wc > 10)
{
++wordTable[11];
}
else if(wc <=10 && wc > 0) //otherwise it will count newline
{
++wordTable[wc];
}
wc=0;
}
}
for(counter = 1; counter < ARRAY_SLOTS; ++counter)
{
if(wordTable[counter] > wordTable[0])
{
wordTable[0] = wordTable[counter];
}
}
for(counter = wordTable[0]; counter > 0; counter--)
{
printf("%7d|", counter);
for(stars = 1; stars <= ARRAY_SLOTS; stars++)
{
if(wordTable[stars]>=counter)
{
printf("* ");
}
else
{
printf(" ");}
}
printf("n");
}
printf(" ");
for(counter = 1; counter < ARRAY_SLOTS ; ++counter)
{
printf("---");
}
printf("n ");
for(counter = 1; counter < ARRAY_SLOTS ; ++counter)
{
if(counter < 11)
{
printf("%2d ",counter);
}
else{
printf(" moren");
}
}
return 0;
}
The C Programming Language Chapter 1 Exercise 1-14
这个有点太坏了,难度不算是很高吧,这才第二十四页呀。。。。不过很有趣。
这里有“标准答案”。不过我的跟他的不同,我只用到两个变量,一个数组~~
要求: Write a program to print a histogram of the frequencies of different characters in its input.
#include
//there are 94 visible chars in ascii table
//make an array that holds 95 ints, the array[0]
//holds the the maximum char.
#define ARRAY_SLOT 96
int main(int argc, char *argv[])
{
int c,stars;
int charTable[ARRAY_SLOT];
for (c=0; c < ARRAY_SLOT ; c++ )
{
charTable[c]=0;
}
while ((c = getchar())!= EOF)
{
//visible ascii is from 32 to 126
if (c>=32 && c<=126)
{
//input to array, charTable[1] to charTable[95]
++charTable[c-31];
}
else if (c='n')
{
;
}
else
{;}
}
for (c=1;ccharTable[0])
{
//charTable[0] for the biggest number
charTable[0] = charTable[c];
}
}
for (c = charTable[0]; c > 0; c-- )
{
printf("%4d|",c);
for (stars=1; stars < 96 ;stars++ )
{
if (charTable[stars]!=0)
{
if (charTable[stars]>=c)
{
printf("*");
}
else{
printf(" ");
};
}
else
; //do nothing.
}
printf("n");
}
printf(" ");
for(c = 1; c < ARRAY_SLOT ; ++c)
{
if (charTable[c])
{
printf("-");
}
}
printf("n ");
for (c=1; c
what do you need to do to run "backup" PSN games on geohot's 3.55 cfw
google is your friend, and you’ll need a few things:
1. PSL1GHT vm and VirtualBox
2. geohot’s signing tools, at geohot.com
3. PS3 tools from fail0verflow
4. ftp server for PS3
5. little experiences with linux terminal.
you can get cracked games from PS3ISO.com, these games don’t work directly with geohot’s cfw because this cfw is not allowing of running unsigned/modified EBOOT.BIN. what we have to do is very simple: to sign the EBOOT.BIN using geohot’s signing tools: make_self_npdrm and package_finalize.
first you need to set up the environment, in VM, and everything is done in terminal:
1. get geohot’s tools, git clone https://github.com/geohot/ps3publictools.git ,and compile them with “make linux”, then cp these files to /usr/bin, the password is “password”
2. go to ~/dev/ps3/ps3tools and “make”, then copy ‘unself’ to /usr/bin
On PS3: install a ftp server, get it here: http://www.megaupload.com/?d=CZBW58WW
Get the game you like from PS3ISO.com
if game.pkg installs:
1. get EBOOT.BIN from PS3 and run:
2. run “unself EBOOT.BIN eboot.elf”
3. and run “make_self_npdrm eboot.elf EBOOT.BIN [content id]“. use “PS3_SFO_Editor_LE.gambas” to read content id, or simply use game folder name.
4. copy the new EBOOT.BIN to the game folder, done.
If the game.pkg won’t install, just use package_finalize on the game.pkg:
1. run “package_finalize game.pkg” and you should be able to run the install, then,
2. get EBOOT.BIN from PS3 and run:
3. run “unself EBOOT.BIN eboot.elf”
4. and run “make_self_npdrm eboot.elf EBOOT.BIN [content id]“. use “PS3_SFO_Editor_LE.gambas” to read content id, or simply use game folder name.
5. copy the new EBOOT.BIN to the game folder, done. (yea…same shit..)
Tested on Lumine : supernova and echochrome.
Getting Skillsoft Course Manager (SCM) to work with OSX Snow Leopard
I’ve used VM to run Skillsoft Course Manager since day one because I don’t have a PC… It’s a bit inconvenience, obviously. So after a simple googling I found there is a version for Mac… -_-
However, after visiting Client Download for Mac and installing a Mac SCM, it didn’t appare to work…
I have OSX Snow Leopard with the lastest updates, including JAVA SE build 1.6.0_22-b04-307-10M3261 installed. And the fix was easy, well after 2 hours of my time -_- .
in ~/Applications/SkillSoft/SkillSoftContent/client/ you’ll find MacOCMStart.sh, this script executes the java contents and runs the program for you. In this file, whenever you see “exec java -Xdock:name=….”, you change it to “exec java -d32 -Xdock:name=….”
That’s it!
Oh if you didn’t pay for it (you know what I meant
), copied the “Content” folder from Windows’s version, and when asked for the user ID, use “REBELS – We Make All Days Party Days!” without the quotation mark.
UPDATE: Mah, the SCM is too old I guess…when play on mac it has no sound
check the spec, they said it supports only 10.4…..oh well….
Passed CompTIA A+ exams
After almost a month of preparation, I took and passed the CompTIA A+ test today, in coming weeks I’ll be receiving the certification document from CompTIA. YAY
To be honest it’s not a hard test, that’s why it’s known as “entry level” of IT support certification. Any person with computer repairing experience and study the material would pass this set of 2 exams. But still, studying is a big part of this.
There are 2 parts of the exam:
220-701: CompTIA A+ Essentials and,
220-702: CompTIA A+ Practical Application.
I was pretty not confident when I take the Practical Applications because it was somewhat confusing while answering the questions. Yet surprisingly I’ve done better than I expected. 810 out of 900, phew…I was not dare to look on the screen when I click “End exam” because I was so afraid there were a big “Fail” on the screen…..
The material I used to prepare the test was:
CompTIA A+ Certification All-in-One Exam Guide, Seventh Edition and,
Skillsoft’s interactive course software.
The book is a great book, but….it’s an overkill! I read half of it and gave up
it’s got 1300+ pages.
The interactive course is good stuff. I was able to take a pre-test before a new topic, and went through the topic, then take the skill test again. I think it’s good way of studying, if I got the software first, I wouldn’t have to read the book LOL.
My next objective is the CompTIA Network+. Wish myself luck
把 blog 从 textcube 换成 WordPress 了
好久好久没上来写东西,主要是日复一日的生活实在缺少那些值得分享的因素。偷偷看了自己的blog一眼,觉得太凄凉了。 Facebook, twitter 之类的商业机器把个人的 blog 热情弄没了 -_-
第七章, Core Data Basics
這章主要講解如何使用 Cocoa 的 NSManagedObject 來做簡單的數據管理程序。
[code lang-c]-(BOOL)validateName:(id *)ioValue error:(NSError **)outError
{
if (*ioValue == nil){
return YES;
}
if ([*ioValue isEqualToString:@"Bob"]){
if (outError != NULL) {
NSString *errorStr = NSLocalizedString(
@"You're not allowed to name a mythical person 'Bob'."
"'Bob'is a real person, just liek you and me.",
@"validation:invalid name error");
NSDictionary *userInfoDict = [NSDictionary dictionaryWithObject:errorStr forKey:NSLocalizedDescriptionKey];
NSError *error = [[[NSError alloc] initWithDomain:@"MythicalPersonErrorDomain" code:13013 userInfo:userInfoDict] autorelease];
*outError = error;
}
return NO;
}
return YES;
}
目前比較讓我摸不著頭腦的是 NSError 的方法們,應該用多了就能熟悉。
還有就是驗證多個 properties, 需要 Implement
[code]- (BOOL)validateForInsert:(NSError **)error[/code]和[code]- (BOOL)validateForUpdate:(NSError **)error [/code]這兩個方法。