Skip to main content

Posts

Showing posts from March, 2020

Notes on using ssh-agent with git and other program

ssh-agent bash -c 'ssh-add /somewhere/yourkey; git clone git@github.com:user/project.git' I often used this way few year ago, just noted here. You may have to add sudo somewhere in command above. Use with rsync ssh-agent bash -c 'ssh-add /home/KfW/KEYs/id_rsa; rsync -avz root@123.199.154.222:/var/www/somesite/uploads .' Oh too much (Enable nginx debugging) http://nginx.org/en/docs/debugging_log.html https://serverfault.com/questions/333048/best-way-to-debug-nginx-config-file Nginx image resize on the fly not work.

git: branches/pull diverged; how to proceed?

Your branch and 'origin/develop' have diverged, and have 34 and 12 different commits each, respectively.   (use "git pull" to merge the remote branch into yours) You have unmerged paths.   (fix conflicts and run "git commit")   (use "git merge --abort" to abort the merge) Changes to be committed:     modified:   Project/Config.swift     modified:   Podfile.lock ... Unmerged paths:   (use "git add <file>..." to mark resolution)     both modified:   Project.xcodeproj/project.pbxproj     both modified:   Project/Scene/Posting/PostingScene.storyboard ... Untracked files:   (use "git add <file>..." to include in what will be committed)     .gitallowed https://stackoverflow.com/questions/8716130/git-branches-diverged-how-to-proceed

MySQL root account blocked (5.7 root require sudoer), password strength etc

https://sysfiddler.com/mysql-error-1819-hy000-your-password-does-not-satisfy-the-current-policy-requirements/ only_full_group_by https://stackoverflow.com/questions/34115174/error-related-to-only-full-group-by-when-executing-a-query-in-mysql https://stackoverflow.com/questions/36864206/sqlstatehy000-1698-access-denied-for-user-rootlocalhost Turns out you can't use the root user in 5.7 anymore without becoming a sudoer. That means you can't just run mysql -u root anymore and have to do sudo mysql -u root instead. That also means that it will no longer work if you're using the root user in a GUI (or supposedly any non-command line application). To make it work you'll have to create a new user with the required privileges and use that instead. https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7/763359#763359 SQL dump data extended insert or not (or batched). Knowing how to dump database properly is useful in robust development or d...

Some patterns related articles

https://sourcemaking.com/design_patterns/strategy https://en.wikipedia.org/wiki/Adapter_pattern https://stackoverflow.com/questions/51165280/best-design-pattern-to-avoid-instanceof-when-working-with-classes-that-cannot-be https://refactoring.guru/design-patterns/adapter https://blog.bitsrc.io/keep-it-simple-with-the-strategy-design-pattern-c36a14c985e9 https://roadmap.sh/guides/design-patterns-for-humans

Eloquent Join, Cross Join, Advanced Join Clauses, Sub-query Joins, migration schema unique two column

I am a forgetful one. So many time I have to dig into documentation that with normal developer can/often remember. https://laravel.com/docs/5.8/queries https://stackoverflow.com/questions/1463363/how-do-i-rename-an-index-in-mysql https://stackoverflow.com/questions/51497890/how-to-search-case-insensitive-in-eloquent-model Yeah damp PHP check string empty IT should be != '' otherwise " " blank or space not empty ? My be I have to trim it first ? if empty( trim($locality) ) {} ($locality != '') This is it, Why/How automatic where condition added to Eloquent ? https://stackoverflow.com/questions/14271812/laravel-set-an-automatic-where-clause in query() method of Model  public function query() // newQuery in Laravel 4 {     $query = parent::query();     $query->where('deleted','=','0');     return $query; } But I can not find any override (?) of this function in my Model or BaseModel. It is strange. Back ...

Bash nohup without output, DB design junction table etc

https://stackoverflow.com/questions/10408816/how-do-i-use-the-nohup-command-without-getting-nohup-out nohup command >/dev/null 2>&1   # doesn't create nohup.out nohup command >/dev/null 2>&1 & # runs in background, still doesn't create nohup.out Job description Requirements: 5 years minimum of professional experience in Software Engineering. Experience with any or all of the following technologies is a plus: Node.js, React, TypeScript. Startup experience valued. Our company: Did you know that 90% of all goods globally are transported through a container, and the largest container vessels are 400 meters long and can transport 20,000 containers at a time? The container shipping industry is the back-bone and enabler of global trade, but it is struggling. At its core the industry is fundamentally inefficient: 50% of all container vessels globally are delayed coming into port, and key planning processes are done manually on a global scale. This...

Multi-country adress database design

MULTI-COUNTRY ADDRESS DATABASE DESIGN http://danielcoding.net/multi-country-address-database-design/ https://stackoverflow.com/questions/929684/is-there-common-street-addresses-database-design-for-all-addresses-of-the-world http://www.upu.int/uploads/tx_sbdownloader/productSheetPostcodesDatabaseEn.pdf http://www.upu.int/en/resources/postcodes/universal-postcoder-database.html Google Place Detail API reveal some useful about its data structure design, and sure it very cool. https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJGzHG3iMT5TQRgQ6MsXnL7xQ&key=GG_KEY_HERE&language=ja    "result" : {       "address_components" : [          {             "long_name" : "8",             "short_name" : "8",             ...

PHP str_pad, Laravel PHP static function call

https://www.php.net/manual/en/function.str-pad.php Useful when for example add 0000 prefix to and ID (int) STR_PAD_LEFT / RIGHT https://www.w3resource.com/mysql/string-functions/mysql-lpad-function.php https://stackoverflow.com/questions/3446538/cleanest-way-to-skip-a-foreach-if-array-is-empty https://laravel.io/forum/07-28-2014-error-using-this-when-not-in-object-context $table is an instance variable, not a static variable, so you can't use it in a static function (basic PHP). Damn basic PHP that I miss, and many interview question asked this shit. Yeah, update Model func remove static and update Controller call: // Model public function findMyReviewedShop()  {} // Controller $data = (new AreaModel)->findMyReviewedShop($user_id, $area_id); // instead of :: https://stackoverflow.com/questions/34947862/how-to-use-hasmanythrough-with-more-than-3-tables-in-laravel Questions: 1. Is relation query return all related data ? ie. review->shopdata ... This is...

React catch up 2

https://github.com/InfiniteLibrary/infinite-reader https://reactjs.org/tutorial/tutorial.html Funny geohot meditation Some shit ab REST API https://medium.com/@petertboyer/learn-restful-api-design-ideals-c5ec915a430f ie. 400 code indicate requested information is incomplete or malformed. https://www.quora.com/Should-every-table-in-a-database-have-an-ID-column short answer is yes since requirement change all the time and out weight normalization  (in most case) ? https://stackoverflow.com/questions/16815551/how-to-do-this-in-laravel-subquery-where-in Products::whereIn('id', function($query){     $query->select('paper_type_id')     ->from(with(new ProductCategory)->getTable())     ->whereIn('category_id', ['223', '15'])     ->where('active', 1); })->get(); Faster port check on OSX sudo lsof -i :8081 alias port3='sudo lsoft -i ' usage: port3 :8081 - You will be part of an agi...

DB design is it wise to have huge JSON row or column inside Relational Database ?

https://softwareengineering.stackexchange.com/questions/215429/is-it-wise-to-store-a-big-lump-of-json-on-a-database-row Debug datetime sort error  // get last updated review inside a shop (max two latest reviews)  if(isset($a['my_reviews'][1])) {      if( strtotime(@$a['my_reviews'][1]['updated_at']) > strtotime($a_last_updated) ) {          if (strpos(@$a['my_reviews'][0]['updated_at'], '2019-01-17') !== false) {              Log::debug(@$a['my_reviews'][0]['updated_at']. " " .@$a['my_reviews'][1]['updated_at']);          }          @$a['my_reviews'][0]['updated_at'] = @$a['my_reviews'][1]['updated_at'];          if (strpos(@$a['my_reviews'][0]['updated_at'], '2019-01-17') !== false) {       ...

DB design new table vs new columns Post, Location/Place and Datetime

https://www.red-gate.com/simple-talk/sql/database-administration/five-simple-database-design-errors-you-should-avoid/ This post have described some useful technique to avoid and reduce mistake on DB design. It seem all the shitty design here that Wordpress have it all :) Even though you can see why WP use this way, but after all as a Web/Software developer I feel WP should not be used in complex and important site ie. payment ... https://dba.stackexchange.com/questions/188667/best-database-and-table-design-for-billions-of-rows-of-data   https://www.quora.com/What-is-Facebooks-database-schema https://www.facebook.com/notes/facebook-engineering/tao-the-power-of-the-graph/10151525983993920 Certainly, FB implement or any other big tech are out of  normal solution, so it is for reference and research only (?) [ https://www.quora.com/What-is-Facebooks-database-schema ] In normal implementation we mostly use Relational DB design or noSQL. For example User and Friend tab...

Notes on add password to existing ssh-rsa key, can not connect to EC2 using private key, using supervisord on Amazon EC2 etc.

https://stackoverflow.com/questions/3818886/how-do-i-add-a-password-to-an-openssh-private-key-that-was-generated-without-a-p Supervisord https://serverfault.com/questions/672891/supervisor-setup-on-aws-ami-linux https://security.stackexchange.com/questions/59136/can-i-add-a-password-to-an-existing-private-key This one work for me, so I do not try another method openssl rsa -aes256 -in your.key -out your.encrypted.key mv your.encrypted.key your.key chmod 600 your.key Damn my bone head I know that Laravel queue require beanstalkd and or supervisord or similar to automatically start queue. But when investigate old server for upgrade, I only focus on beanstalkd. So now I have to migrate supervisord configurations after sever roll out to production. Config here http://supervisord.org/configuration.html https://stackoverflow.com/questions/1968773/view-stored-procedure-function-definition-in-mysql https://stackoverflow.com/questions/51908004/install-phpredis-mac-osx supe...