Category: dev


RJ-45自製網路線

測線器,一個發射端,一個接收端,上面8顆燈號

發射端會依序打出信號 1~8號燈,然後看接收器 1~8號燈 有沒有亮。

沒亮 = 線材中間斷蕊

亮的燈號順序不對 = 壓頭蕊線顏色排列錯誤,重壓

rj45

rj45-2

Reference: http://blog.xuite.net/axian/blog/224348022-%E8%87%AA%E5%B7%B1%E5%8B%95%E6%89%8B+DIY+RJ45+%E7%B6%B2%E8%B7%AF%E7%B7%9A%E6%8E%A5%E9%A0%AD%E5%90%A7%EF%BC%81

廣告

SVN 1.8 on OSX (El Capitan)

UPDATE: 2015/10/27

For fresh install of El Capitan, Folks at HomeBrew has done the fine work for us.  From now we can just get it setup with brew.
brew install svn

 

UPDATE: 2014/10/27

Now we are in the era of OSX 10.10 (Yosemite) and the build method below is troublesome, particular with serf.

Folks at HomeBrew has done the fine work for us.  From now we can just get it setup with brew.
brew install subversion
this will get you subversion 1.8.10 at /usr/local/Cellar/subversion/1.8.10.1
As brew doesn’t override the system default, let’s do it ourself:


cd /usr/bin
ls -la svn*

You see the svn executables. Just rename and relink them. For example,


sudo mv svn svn1.7
sudo ln -s /usr/local/Cellar/subversion/1.8.10_1/bin/svn ./svn

Finally, force brew to link and overwrite all conflicting files:

brew link --overwrite subversion

 

This post is about how to compile the latest SVN source (1.8.3) on OSX Mavericks (OSX 10.9).

References

Sam’s Updating to SVN 1.8 for Mac OSX 10.8. This is about building in OSX 10.8.

Requirement

  1. Xcode command line tool: can be download at Apple’s dev center or install command line tool without Xcode.
  2. Setup the Tool chain:
    sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain
    The key is to link the toolchain to reflect new version # of Maverick, which is 10.9.
  3. The SVN source: can be download form Apache SVN project.
    Here’s straight way in command:
    cd ~/Downloads/
    curl -o subversion-1.8.3.tar.gz http://archive.apache.org/dist/subversion/subversion-1.8.3.tar.gz
    tar -xvf subversion-1.8.3.tar.gz

Build and Install SVN

Build serf

First we will need to build serf, included in the subversion package.
cd ~/Downloads/subversion-1.8.3
sh get-deps.sh serf
cd serf/
./configure
make
sudo make install

Build SVN

Go back up to the SVN source root, and build it using serf. Depend on your hardware, it might takes awhile. If you need a coffee, this is good time to do so once you start the make.

cd ..
./configure --prefix=/usr/local --with-serf=/usr/local/serf
make
sudo make install

Wrap it up

Now you’ve the new SVN 1.8.3 installed at /usr/local/bin. Make sure your path includes it. From there you should able to:
svn --version

And here you go:

svn, version 1.8.3 (r1516576)
   compiled Oct 24 2013, 02:38:35 on x86_64-apple-darwin13.0.0

Copyright (C) 2013 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository access (RA) modules are available:

* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
  - using serf 1.2.1
  - handles 'http' scheme
  - handles 'https' scheme

Mac: Reset home folder permissions

This is for Mountain Lion.

http://www.fixkb.com/2011/08/reset-home-folder-permissions.html

  1. In Terminal, type sudo bash and press Enter.
  2. You will need to enter your password and press Enter.
    • It won’t show any characters when you type.
    • If you do not have a password then set one first.
  3. Type in the following (case-sensitive), pressing Enter at the end of each line.
    Replace “username” with the name of your home folder.
    sudo chmod -R -v -N ~
    sudo chown -R username:staff ~
    sudo chmod -R -v 700 ~
    sudo chmod -v 755 ~

Generating Video Thumbnails With FFMPEG

Check out flowplayer’s – http://flowplayer.org/tutorials/generating-thumbs.html

In short,

ffmpeg -i [video_file] -f image2 -vframes 1 [output_image].jpg

For example,

ffmpeg -ss 12 -i flowplayer.mov -f image2 -vframes 1 flowplayer-12.jpg

In ffmpeg, you can determine video or image file info:


ffmpeg -i my_video_filename

Another option is exiftool tool.

1. Install on RHEL
yum install perl-Image-ExifTool.noarch
**you need to have rpmforge repository installed.

2. Use it
exiftool my_video_file

if you get this error, it’s because Sliverlight assembly is not in GAC. Do this to fix:


cd C:Program FilesMicrosoft Silverlight4.0.50524.0
gacutil -i System.Core.dll
gacutil -i system.dll
gacutil -i system.net.dll
gacutil -i system.xml.dll
gacutil -i System.Runtime.Serialization.dll

check out what other people said.

If you get something like this:

Server Error in '/applicationname' Application.
---------------------------------------------------------------------------
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Requested registry access is not allowed.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[SecurityException: Requested registry access is not allowed.]
Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +473
....

I’m not sure there’s a secured way, but adding permission for iis daemon user solve the problem for me.

1. Find out which deamon user your app is using, by looking up App_Pool and secruity section in event log.

2. Give the user permission to read/write access for the eventlog registry entry. To do so, open regedit and navigate to the key:

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesEventlog

.
Right click and select Permissions, and add permission for the user.

3. restart iis and give it a try.

MySQL 5.x Repair Cheat Sheet

If you upgrade MySQL or move the database around, you are most likely need to do those operations:

Backup

mysqldump -u root -p --default-character-set=utf8 databasename > data.sql

Restore

mysqldump -u root -p --default-character-set=utf8 databasename < data.sql
if database is larger then 100MB, this works better:
mysql -u root -p
#mysql> use the_database
#mysql> source data.sql

Check, Repair & Optimize All Tables in All Databases

If you need database server up, use mysqlcheck:
mysqlcheck -u root -p --auto-repair --check --optimize --all-databases

Or you can make it offline and do a better check:
service mysqld stop
myisamchk /var/lib/mysql/the_database/*.MYI
service mysqld start

Repair single table

mysql -u root -p
#mysql> use the_database
#mysql> repair table the_table

Reference:
http://www.felipecruz.com/repair-mysql-database.php

MySQL 5.1.x & unicode

In our recent upgrade from 5.0 to 5.1.47, the new version behaves differently and it screw up character set when user submit info from our web app powered by .NET.

After digging around for a afternoon, this is how to fix it:

vi /etc/my.cnf

And add those lines to the config:

init_connect='SET collation_connection = utf8_general_ci'
init_connect='SET NAMES utf8'
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake

There are other options for collation besides utf8_general_ci such as utf8_unicode_ci. See this article:
http://dev.mysql.com/doc/refman/5.1/en/charset-unicode-sets.html

Reference: http://rhyous.com/2009/11/05/how-to-create-a-utf-8-unicode-database-on-mysql/

XShell from NetSarang is a great SSH client that we use. Even one awhile, you might wanna back up all the saved profiles.

The profiles are actually located at: %user_profile%\%username%\AppData\Roaming\NetSarang\Xshell. For example, C:\Users\johnny\AppData\Roaming\NetSarang\Xshell.

You can just copy the directory to where you want to back it up. You can also create sub-directories if you want to manage them a bit.