Archive

Tag Archives: cmd

Unable to install Homebrew with this?

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

What’s happened

-e:70: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
Password:
==> Downloading and installing Homebrew...
remote: Counting objects: 192274, done.
remote: Compressing objects: 100% (52298/52298), done.
remote: Total 192274 (delta 138823), reused 192246 (delta 138803)
Receiving objects: 100% (192274/192274), 38.59 MiB | 189 KiB/s, done.
Resolving deltas: 100% (138823/138823), done.
From https://github.com/Homebrew/homebrew
 * [new branch]      master     -> origin/master
error: unable to unlink old 'Library/Aliases/0mq' (Permission denied)
error: unable to unlink old 'Library/Aliases/4store' (Permission denied)
error: unable to unlink old 'Library/Aliases/Secret Rabbit Code' (Permission denied)
error: unable to unlink old 'Library/Aliases/ag' (Permission denied)
error: unable to unlink old 'Library/Aliases/alut' (Permission denied)
error: unable to unlink old 'Library/Aliases/android' (Permission denied)
error: unable to unlink old 'Library/Aliases/apache-activemq' (Permission denied)
error: unable to unlink old 'Library/Aliases/apache-fop' (Permission denied)
error: unable to unlink old 'Library/Aliases/aws-as' (Permission denied)
error: unable to unlink old 'Library/Aliases/aws-mon' (Permission denied)
error: unable to unlink old 'Library/Aliases/beanstalkd' (Permission denied)
error: unable to unlink old 'Library/Aliases/bjam' (Permission denied)
error: unable to unlink old 'Library/Aliases/boehmgc' (Permission denied)
error: unable to unlink old 'Library/Aliases/boost-jam' (Permission denied)
error: unable to create symlink Library/Aliases/boot2docker-cli (Permission denied)
error: unable to unlink old 'Library/Aliases/bzr' (Permission denied)
error: unable to unlink old 'Library/Aliases/cowthink' (Permission denied)
error: unable to unlink old 'Library/Aliases/cpanm' (Permission denied)
error: unable to unlink old 'Library/Aliases/csvfix' (Permission denied)
error: unable to unlink old 'Library/Aliases/ctags-exuberant' (Permission denied)
error: unable to unlink old 'Library/Aliases/db' (Permission denied)
error: unable to unlink old 'Library/Aliases/dbus' (Permission denied)
error: unable to unlink old 'Library/Aliases/dejagnu' (Permission denied)
error: unable to unlink old 'Library/Aliases/eyeD3' (Permission denied)
error: unable to unlink old 'Library/Aliases/fastcgi' (Permission denied)
error: unable to unlink old 'Library/Aliases/fishfish' (Permission denied)
error: unable to unlink old 'Library/Aliases/fluidsynth' (Permission denied)
error: unable to unlink old 'Library/Aliases/gearmand' (Permission denied)
error: unable to unlink old 'Library/Aliases/git-tig' (Permission denied)
error: unable to unlink old 'Library/Aliases/gnu-scientific-library' (Permission denied)
error: unable to unlink old 'Library/Aliases/google-go' (Permission denied)
error: unable to unlink old 'Library/Aliases/gperftools' (Permission denied)
error: unable to unlink old 'Library/Aliases/gpg' (Permission denied)
error: unable to unlink old 'Library/Aliases/gpg2' (Permission denied)
error: unable to unlink old 'Library/Aliases/gs' (Permission denied)
error: unable to unlink old 'Library/Aliases/gtk' (Permission denied)
error: unable to unlink old 'Library/Aliases/gtypist' (Permission denied)
error: unable to unlink old 'Library/Aliases/hashdeep' (Permission denied)
error: unable to unlink old 'Library/Aliases/heroku' (Permission denied)
error: unable to unlink old 'Library/Aliases/hg' (Permission denied)
error: unable to unlink old 'Library/Aliases/htop' (Permission denied)
error: unable to unlink old 'Library/Aliases/hudson' (Permission denied)
error: unable to unlink old 'Library/Aliases/ipsum' (Permission denied)
error: unable to unlink old 'Library/Aliases/jocr' (Permission denied)
error: unable to unlink old 'Library/Aliases/lcms' (Permission denied)
error: unable to unlink old 'Library/Aliases/lcms2' (Permission denied)
error: unable to unlink old 'Library/Aliases/leg' (Permission denied)
error: unable to unlink old 'Library/Aliases/libcryptopp' (Permission denied)
error: unable to unlink old 'Library/Aliases/libgd' (Permission denied)
error: unable to unlink old 'Library/Aliases/libgeoip' (Permission denied)
error: unable to unlink old 'Library/Aliases/libjpeg' (Permission denied)
error: unable to unlink old 'Library/Aliases/libjpeg-turbo' (Permission denied)
error: unable to unlink old 'Library/Aliases/libjpg' (Permission denied)
error: unable to unlink old 'Library/Aliases/liblabjackusb' (Permission denied)
error: unable to unlink old 'Library/Aliases/libmad' (Permission denied)
error: unable to unlink old 'Library/Aliases/libmcrypt' (Permission denied)
error: unable to unlink old 'Library/Aliases/libnettle' (Permission denied)
error: unable to unlink old 'Library/Aliases/liboggz' (Permission denied)
error: unable to unlink old 'Library/Aliases/libqrencode' (Permission denied)
error: unable to unlink old 'Library/Aliases/libtag' (Permission denied)
error: unable to unlink old 'Library/Aliases/libtasn' (Permission denied)
error: unable to unlink old 'Library/Aliases/libtcnative' (Permission denied)
error: unable to unlink old 'Library/Aliases/littlecms' (Permission denied)
error: unable to unlink old 'Library/Aliases/mc' (Permission denied)
error: unable to unlink old 'Library/Aliases/mediainfo' (Permission denied)
error: unable to unlink old 'Library/Aliases/mongo' (Permission denied)
error: unable to unlink old 'Library/Aliases/mosh' (Permission denied)
error: unable to unlink old 'Library/Aliases/mp4box' (Permission denied)
error: unable to unlink old 'Library/Aliases/mpich' (Permission denied)
error: unable to unlink old 'Library/Aliases/myrepos' (Permission denied)
error: unable to unlink old 'Library/Aliases/node.js' (Permission denied)
error: unable to unlink old 'Library/Aliases/nodejs' (Permission denied)
error: unable to unlink old 'Library/Aliases/npm' (Permission denied)
error: unable to unlink old 'Library/Aliases/nsis' (Permission denied)
error: unable to unlink old 'Library/Aliases/o-caml' (Permission denied)
error: unable to unlink old 'Library/Aliases/ocaml' (Permission denied)
error: unable to unlink old 'Library/Aliases/ocio' (Permission denied)
error: unable to unlink old 'Library/Aliases/offlineimap' (Permission denied)
error: unable to unlink old 'Library/Aliases/ooc' (Permission denied)
error: unable to unlink old 'Library/Aliases/openmpi' (Permission denied)
error: unable to unlink old 'Library/Aliases/openocd' (Permission denied)
error: unable to unlink old 'Library/Aliases/pgrep' (Permission denied)
error: unable to unlink old 'Library/Aliases/pipeviewer' (Permission denied)
error: unable to unlink old 'Library/Aliases/pkgconfig' (Permission denied)
error: unable to unlink old 'Library/Aliases/pkill' (Permission denied)
error: unable to unlink old 'Library/Aliases/pocketsphinx' (Permission denied)
error: unable to unlink old 'Library/Aliases/postgres' (Permission denied)
error: unable to create symlink Library/Aliases/pt (Permission denied)
error: unable to unlink old 'Library/Aliases/qt4' (Permission denied)
error: unable to unlink old 'Library/Aliases/shell-fm' (Permission denied)
error: unable to unlink old 'Library/Aliases/slang' (Permission denied)
error: unable to unlink old 'Library/Aliases/sphinxbase' (Permission denied)
error: unable to unlink old 'Library/Aliases/sqlite3' (Permission denied)
error: unable to unlink old 'Library/Aliases/stax-sdk' (Permission denied)
error: unable to unlink old 'Library/Aliases/style' (Permission denied)
error: unable to unlink old 'Library/Aliases/svn' (Permission denied)
error: unable to unlink old 'Library/Aliases/tinyfugue' (Permission denied)
error: unable to create symlink Library/Aliases/twemproxy (Permission denied)
error: unable to unlink old 'Library/Aliases/twolame' (Permission denied)
error: unable to unlink old 'Library/Aliases/unix2dos' (Permission denied)
error: unable to unlink old 'Library/Aliases/urxvt' (Permission denied)
error: unable to unlink old 'Library/Aliases/usb-multiplex-daemon' (Permission denied)
error: unable to create symlink Library/Aliases/vid.stab (Permission denied)
error: unable to unlink old 'Library/Aliases/wxwidgets' (Permission denied)
error: unable to unlink old 'Library/Aliases/xmlsec1' (Permission denied)
error: unable to unlink old 'Library/Aliases/zmq' (Permission denied)
error: unable to unlink old 'Library/Contributions/brew_bash_completion.sh' (Permission denied)
error: unable to unlink old 'Library/Contributions/brew_fish_completion.fish' (Permission denied)
error: unable to unlink old 'Library/Contributions/brew_zsh_completion.zsh' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-aspell-dictionaries.rb' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-beer.rb' (Permission denied)
error: unable to create file Library/Contributions/cmd/brew-bundle-dir.rb (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-bundle.rb' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-cleanup-installed' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-gist-logs.rb' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-graph' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-man' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-profile.rb' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-pull.rb' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-server' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-services.rb' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-switch.rb' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-tap-readme.rb' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-test-bot.rb' (Permission denied)
error: unable to create file Library/Contributions/cmd/brew-versions.rb (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/brew-which.rb' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/git' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/public/bootstrap.min.css' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/public/glyphicons-halflings-white.png' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/public/glyphicons-halflings.png' (Permission denied)
error: unable to unlink old 'Library/Contributions/cmd/svn' (Permission denied)
error: unable to unlink old 'Library/Contributions/example-formula.rb' (Permission denied)
error: unable to unlink old 'Library/Contributions/manpages/brew.1.md' (Permission denied)
error: unable to unlink old 'Library/ENV/3.2.6' (Permission denied)
error: unable to unlink old 'Library/ENV/4.2' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/ant' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/apr-1-config' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/bsdmake' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/c++' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/c89' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/c99' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/cc' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/clang' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/clang++' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/cpp' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/g++' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/g++-4.2' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/g++-4.3' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/g++-4.4' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/g++-4.5' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/g++-4.6' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/g++-4.7' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/g++-4.8' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/g++-4.9' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/gcc' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/gcc-4.2' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/gcc-4.3' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/gcc-4.4' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/gcc-4.5' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/gcc-4.6' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/gcc-4.7' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/gcc-4.8' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/gcc-4.9' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/git' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/gmake' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/i686-apple-darwin11-llvm-g++-4.2' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/i686-apple-darwin11-llvm-gcc-4.2' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/ld' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/llvm-g++' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/llvm-g++-4.2' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/llvm-gcc' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/llvm-gcc-4.2' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/make' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/mig' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/pod2man' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/sed' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/svn' (Permission denied)
error: unable to unlink old 'Library/ENV/4.3/xcrun' (Permission denied)
fatal: cannot create directory at 'Library/ENV/pkgconfig/10.10': Permission denied
Failed during: git reset --hard origin/master

Reason

Probably you have multiple users on your computer. And you uninstalled the old Homebrew and trying to re-install it.

Solution

Theorotically you can remove the directory /usr/local/Library but this will happens again when you try to use Homebrew with another user. It is better to change the permission of directory with this:

sudo chmod -R 775 /usr/local/Library

and after a successful install, you better fix the permission for another directory. This directory may appear after you run some ruby commands.

sudo chmod -R 775 /usr/local/Cellar

 

I know it is troublesome, tedious, or just like hell. Apple has his own way to do a common task. Very often, we need to use the autocompletion in IDE to assist coding so we do not need to memorize the billions of function names. In Eclipse, everything is automatic. A list of function names linked together with descriptions next to it pops up as soon as you type. In Xcode, where is it? Yes, you need to press shortcuts. For the completions, press “control + space”. But, where are the descriptions? It’s called “quick help”, press “control + command + ?” to open it. Look at the figure then you will understand. Good luck for your fatigued fingers.

While using hit, it is really usual to have regrets on the commits done, especially the name used. In order to change those information in your repository, open terminal (or cmd in windows), go to the folder of your git repositoy, and run the following commands. Remember, replace “old_name”, “new_name” and “new@email.address” with your own information.

git filter-branch --commit-filter '
  if [ "$GIT_COMMITTER_NAME" = "old_name" ];
  then
    GIT_COMMITTER_NAME="new_name";
    GIT_AUTHOR_NAME="new_name";
    GIT_COMMITTER_EMAIL="new@email.address";
    GIT_AUTHOR_EMAIL="new@email.address";
    git commit-tree "$@";
  else
    git commit-tree "$@";
  fi' HEAD

To merge 2 entirely unrelated branches or projects, we need to specify 0 as first revision in revision range. Turn on terminal (in Mac) or cmd (in Windows) and get to your project folder. Merge with the following shell script. merge -r0..-1 means to merge from revision 0 to the latest revision.

bzr merge [other_branch_location] -r0..-1

Normally, we need to go through bunch of clicks to do one action in MS Access. For example, “Compact and Repair Database”. This function can compact your database and make the file smaller. If you never used this, it may take some time to find it. Try it. LOL.

But here I would like to show you how to program it and open this function by click on a button by VBA. Like the screenshot. To achieve that, you should add a module (so that it is easier to be resused), and add the following codes.

Public Sub CompactDatabase()
  CloseAllForms
  SendKeys "%tdc"
End Sub

Alternatively, you can add a question box to prompt comfirmation from user.

Public Sub CompactDatabaseNoticeable()
  If MsgBox( _
    "Are you sure to compact this database?" & vbNewLine & _
    "There is good to compact the database always with no harm!" & vbNewLine & _
    "But this will restart this analyser.", _
    vbYesNoCancel + vbExclamation) = vbYes Then
    CloseAllForms
    SendKeys "%tdc"
  End If
End Sub

Also, you need to add a function to close all the forms so that your applications can focus on the main database window and perform the action.

Public Sub CloseAllForms()
  Dim intIndex As Integer
  For intIndex = Forms.Count - 1 To 0 Step -1
    DoCmd.Close acForm, Forms(intIndex).name, acSaveNo
  Next intIndex
End Sub

After all, you can just add the commands to the click event of your button.

Private Sub CompactButton_Click()
  CompactDatabaseNoticeable
End Sub

We can use shell to execute any programs.

shell("iexplorer")
shell("cmd")

Please be reminded that we may need to execute in an indirect way.

'cmd: execute CMD.exe (Windows Command Processor)
'/c: with commands
'dir: show all things in the default directory
shell ("cmd /c dir")

To make VBA wait until the execution finish and retrieve the result back to the program, we can use this example.

'Global declaration
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32 " (ByVal hHandle As Long) As Long
'Inside program
Dim PathStr
PathStr = "C:Program Filesgzip"
Dim CmdStr
CmdStr = "cmd /c gzip.exe -dkv " & strFileName
ChDir PathStr 'Change the default directory
ProcessId = Shell(CmdStr, vbNormalFocus) 'Run shell to execute program and record the process ID
ProcessHandle = OpenProcess(SYNCHRONIZE, 0, ProcessId) 'Track the process
If ProcessHandle <> 0 Then
  WaitForSingleObject ProcessHandle, INFINITE ' Wait process ends
  CloseHandle ProcessHandle
End If

Suppose we have more than one network adapter, how could we designate the adapter used to access the Internet? One way would be manually configure the default gateway.

Easy way (2 adapters and with little networking knowledge):
Suppose you want to use wireless connection in the condition of having both wire and wireless connection at the same time.

  1. Open up a CMD with administrator right.
  2. Connect internet wire.
  3. Delete default gateway by typing “route delete 0.0.0.0” in CMD opened.
  4. Connect wireless.

Advanced way:
Suppose you have multiple connections to the internet with a number of connections. you can assign default gateway.

  1. Establish all the connections
  2. Open up a CMD with administrator right.
  3. Type “ipconfig /all” and you should be able to see a number of network connections.
  4. Jot down the gateway of the connection you want to use to access the internet.
  5. Delete all the default gateway by typing “route delete 0.0.0.0”.
  6. Create a default gateway to 192.168.0.1 (suppose this is the gateway you want) by typing “route add 0.0.0.0 mask 0.0.0.0 192.168.0.1”.

Also, you can add static routes for hosts you need to reach via any adapter. As a result you can access internet with one connection and send files to friends with another adapter.

  • After the previous steps, Create static routes to 10.1.1.1 (suppose it is your friend’s IP address) via the gateway 192.168.1.1 (suppose it is the desired gateway you want to use to send the files) by typing “route add 10.1.1.1 mask 255.255.255.255 192.168.1.1”.

It is useless to read without a real practice! Try it and you will know how it works!

%d bloggers like this: