Tuesday, August 14, 2018

install ethereum -> Client go & ethconsole set up and running



migration scripts not working, manually remove port
sudo rm -rf /opt/local \
>     /Applications/DarwinPorts \
>     /Applications/MacPorts \
>     /Library/LaunchDaemons/org.macports.* \
>     /Library/Receipts/DarwinPorts*.pkg \
>     /Library/Receipts/MacPorts*.pkg \
>     /Library/StartupItems/DarwinPortsStartup \
>     /Library/Tcl/darwinports1.0 \
>     /Library/Tcl/macports1.0 \
>     ~/.macports


reinstal homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


for install 

npm install -g ethereum-console
ethconsole


gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/ethereum-console/node_modules/scrypt/build'
gyp ERR! System Darwin 17.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/ethereum-console/node_modules/scrypt
gyp ERR! node -v v8.11.3
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt@6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the scrypt@6.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jing/.npm/_logs/2018-08-15T04_11_21_497Z-debug.log


sudo npm install -g ethereum-console --unsafe-perm=true --allow-root


got:

   except ImportError as e:
                        ^
SyntaxError: invalid syntax
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 17.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/ethereum-console/node_modules/scrypt
gyp ERR! node -v v8.11.3
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt@6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1



cd '' && '/usr/bin/pythonw'  '<your script here>'  && echo Exit status: $? && exit 1

force linked to python3.7

brew link --overwrite python


python3 failed



gyp ERR! configure error 
gyp ERR! stack Error: Python executable "/usr/local/bin/python" is v3.7.0, which is not supported by gyp.

brew install python2 && cp /usr/local/bin/python2 /usr/local/bin/python

and  use the other terminal, it will work

brew install python2 && cp /usr/local/bin/python2 /usr/local/bin/python




sudo npm install -g ethereum-console --unsafe-perm=true --allow-root


then finished

ethconsole
ETHEREUM CONSOLE
Connecting to node at /Users/jing/Library/Ethereum/geth.ipc

ERROR
Error: CONNECTION ERROR: Couldn't connect to node on IPC.
Exit due to error.



brew tap ethereum/ethereum
brew install cpp-ethereum
brew linkapps cpp-ethereum



Wednesday, September 28, 2016

js tricks

function fn() {
    this.a = 0;
    this.b = function() {
        alert(this.a)
    }
}
fn.prototype = {
    b: function() {
        this.a = 20;
        alert(this.a);
    },
    c: function() {
        this.a = 30;
        alert(this.a);
    }
}

var myfn = new fn();
myfn.b();
myfn.c();

// result
// 0
// 30


2.

function fun(n,o) {
    console.log(o)
    return {
        fun:function(m){
            return fun(m,n);
        }
    };
}

var a = fun(0); a.fun(1); a.fun(2); a.fun(3);
// undefined, 0 0 0
var b = fun(0).fun(1).fun(2).fun(3);
var c = fun(0).fun(1); c.fun(2); c.fun(3);
// undefined, 0, 1,2
// undefined, 0,1, 1,



reference: web.jobbole.com/88041/

Thursday, November 5, 2015

odoo db postgres ops, import restore; Odoo development Essentials create odoo serevice; api;


 git clone --depth 1 --branch 8.0 https://github.com/odoo/odoo.git odoo8

https://www.odoo.com/forum/help-1/question/website-guest-customer-portal-user-63938
It appears that your package manager failed to create the database named $user for you. The reason that
psql -d template1
works for you is that template1 is a database created by postgres itself, and is present on all installations. You are apparently able to log in to template1, so you must have some rights assigned to you by the database. Try this at a shell prompt:
createdb
and then see if you can log in again with 
psql -h localhost
This will simply create a database for your login user, which I think is what you are looking for. If createdb fails, then you don't have enough rights to make your own database, and you will have to figure out how to fix the homebrew package.
http://stackoverflow.com/questions/17633422/psql-fatal-database-user-does-not-exist
 \l
on mac,shows a list of the databases,


pg_restore -d odoo8 /Users/jing/Documents/repo/dump/dump.sql
pg_restore: [archiver] input file appears to be a text format dump. Please use psql.

http://stackoverflow.com/questions/21122598/postgres-user-does-not-exist
psql odoo8 < /Users/jing/Documents/repo/dump/dump.sql
role "postgres" does not exist
seems it doesn’t matter all tables database created
the race condition with LESS and viewing the website as a logged in editor while also viewing it as a logged out visitor

API

import xmlrpclib
srv,db = ‘http://localhost:8069', ‘v8dev
user,pwd = ‘admin’,’jing
common = xmlrpclib.serverProxy(‘%s/xmlrpc/2/common’ % src)
common.version()

api=xmlrpclib.ServerProxy(‘%s/xmlrpc/2/object’ %srv)
api.execute_kw(db, uid, pwd, ‘res.partner’, ‘search_count’, [[]])


local clone
from stage to the prod site
git clone ~/odoo-dev/odoo ~/odoo-prd/odoo

set up as system service
sudo cp ~/odoo-prd/odoo/debian/init /etc/init.d/odoo
sudo chmod +x /etc/init.d/odoo

open the init, script
sudo ln -s ~/odoo-prd/odoo/odoo.py /usr/bin/openerp-server
sudo chown $(whoami) /usr/bin/openerp-server
create the log file directory
sudo mkdir /var/log/odoo
sudo chown $(whoami) /usr/bin/openerp-server

be able to start /stop odoo service
sudo /etc/init.d/odoo start
being able to get back 
when curl http://localhost:8069
ubuntu
easier command to remember:
sudo service odoo start
start auto on system boot
sudo update-rc.d odoo defaults

Monday, October 26, 2015

fix for broken wkhtmltopdf, odoo9, after a while, the confirmation freezed, python shell freeze at wkhtmltopdf;

wkhtmltopdf version
/Library/Caches/Homebrew/wkhtmltopdf-0.9.9.tar.bz2
rm the above
brew doctor
brew update 
then 
brew install wkhtmltopdf
works
Even in cases where cooperation is intended, misunderstandings and personality incompatibilities can result in an extremely chaotic and hostile environment. Catalysts help prevent and resolve misunderstanding, calm the waters when users have difficulties dealing with each other and provide examples of constructive behavior in environments where such behavior might not otherwise be the norm.
reference: 
https://freenode.net/catalysts.shtml
https://mig5.net/content/adding-yubikey-2-factor-authentication-ssh-and-sudo-debian
PATH=/usr/local/bin;
 openerp.addons.report.models.report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
  • Grab yourself a copy of fresh wkhtmltopdf
  • Open it and drag to Applications
  • Then cd /usr/local/bin && ln -s /Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf wkhtmltopdf
  • reference:
  • http://stackoverflow.com/questions/10375168/how-to-install-and-run-wkhtmltopdf-on-mac-osx-10-7-3-for-use-in-a-php-applicatio
my case, 
os 10.10.3
it is installed directly under /usr/local/bin, no need to ln
and this time,
wkhtmltopdf --version

wkhtmltopdf 0.12.2.1 (with patched qt)
this time, checkout confirmation print out fast, no exec pop out, no freeze
symptoms:
after brew uninstall wkhtmltopdf

"No such keg" when uninstalling formula from URL

when instal brew install wkhtmltopdf
Error: MD5 support has been dropped for security reasons.
Please switch this formula to SHA256.