Showing posts with label Development. Show all posts
Showing posts with label Development. Show all posts

2020-09-28

Unicode normalization

NFD to NFC with convmv
 $ brew install convmv

 # Convert all files in a directory from NFD to NFC:
 $ convmv -f utf-8 -t utf-8 --nfc --notest .

 # Convert all files in a directory from NFC to NFD:
 $ convmv -f utf-8 -t utf-8 --nfd --notest .
NFD to NFC with iconv
 $ iconv -f UTF-8 -t UTF-8-MAC
NFD to NFC with rsync
 $ rsync --iconv=utf-8,utf-8-mac

2020-08-27

SSH with multiple private keys

Add privat keys
 $ ssh-add ~/.ssh/id_rsa_SERVER
Verify keys
 $ ssh-add -l
Test keys
 $ ssh -v URL_TO_HOST
Connect to server
 $ ssh HOSTNAME_OR_ALIAS

2020-05-27

Tensorflow Error : Failed to get convolution algorithm

Tensorflow Error
tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
Solution
  • shell
    export CUDA_VISIBLE_DEVICES=0
  • for tf 2
    import os
    
    os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'
  • for tensorflow-gpu v1.8
    from tensorflow.compat.v1 import ConfigProto
    from tensorflow.compat.v1 import InteractiveSession
    
    config = ConfigProto()
    config.gpu_options.allow_growth = True
    session = InteractiveSession(config=config)

2020-04-17

2019-10-04

GCC 32bit compile on Mac

  • The i386 architecture is deprecated for macOS
    $ gcc -m32 fib.c
    ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
    ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd
    Undefined symbols for architecture i386:
      "_printf", referenced from:
          _main in fib-68f6b9.o
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    
  • Install i386 support
    $ sudo rm -rf /Library/Developer/CommandLineTools
    $ xcode-select --install
    $ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
    
  • Compile
    $ gcc -m32 fib.c
    ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
    
    $ make CFLAGS="-m32" fib
    cc -m32    fib.c   -o fib
    ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
    

2017-11-09

[MAC] convert png to icns with terminal

Use sips to convert png to icns
$ sips
sips 10.4.4 - scriptable image processing system.

This tool is used to query or modify raster image files and ColorSync ICC profiles.
Its functionality can also be used through the "Image Events" AppleScript suite.
Try 'sips --help' or 'sips --helpProperties' for help using this tool

Command
$ sips -s format icns input.png --out output.icns

2017-01-31

How to set DYLD_LIBRARY_PATH in Xcode

Open Product > Scheme > Edit Scheme > Run > Arguments
Add DYLD_LIBRARY_PATH under Environment Variables


dyld: Library not loaded: libboost_system.dylib

Got an error when compile boost library and run a sample program.
$ ./PROGRAM
dyld: Library not loaded: libboost_system.dylib
  Referenced from: /PATH/TO/PROGRAM
  Reason: image not found
Abort trap: 6
Check libraries then tried install_name_tool, but failed.
$ otool -L PROGRAM
PROGRAM:
libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)
libboost_thread.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

$ install_name_tool -change libboost_system.dylib /PATH/TO/libboost_system.dylib PROGRAM
$ install_name_tool -change libboost_thread.dylib /PATH/TO/libboost_thread.dylib PROGRAM
Solution, add the following to .profile or .bash_profile
export DYLD_LIBRARY_PATH=/PATH/TO/BOOST/stage/lib

2014-04-09

enum to int in Java

enum to int

  • ElementOfEnum.ordinal()


int to enum

  • EnumType.values()[someInt]


String to enum

  • EnumType.valueOf(NameOfElement)


enum to String

  • ElementOfEnum.name()

2013-08-23

How to run NginX/PHP/MySQL on Mac


Needed to run DRUPAL on Mac
  1. Install XCode
  2. Install XCode Command Line Tools
  3. XCode > Preferences > Downloads > Command Line Tools
  4. Install Homebrew - Similar to MacPorts but better
  5. $ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
    $ brew doctor
    $ brew tap josegonzalez/homebrew-php
    $ brew tap homebrew/dupes
  6. Install MySQL
  7. $ brew install mysql
    $ unset TMPDIR
    $ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
    $ sudo mv /usr/local/opt/mysql/my-new.cnf /usr/local/opt/mysql/my.cnf
    $ cp `brew --prefix mysql`/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
    $ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  8. Install NginX
  9. $ brew install nginx
    $ sudo cp `brew --prefix nginx`/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/
    $ sudo sed -i -e 's/`whoami`/root/g' `brew --prefix nginx`/homebrew.mxcl.nginx.plist
    $ sudo mkdir /var/log/nginx/
  10. Install PHP
  11. $ brew install --without-apache --with-fpm --with-mysql php54
    $ sudo cp `brew --prefix php54`/homebrew-php.josegonzalez.php54.plist  /Library/LaunchAgents/
    $ sudo launchctl load -w /Library/LaunchAgents/homebrew-php.josegonzalez.php54.plist

2012-10-09

DoEvent for WPF

System.Windows.Application.Current.Dispatcher.Invoke
(
 DispatcherPriority.Background,
 new System.Threading.ThreadStart
 (
  delegate { }
 )
);