Category Archives: Uncategorized

git rebase

ref – https://www.atlassian.com/git/tutorials/merging-vs-rebasing

say you’re on your main branch. and you do a git pull for the latest.

However, you’ve been working your feature branch.
By using rebase, you can cut your branch from its root, and snap it onto main’s HEAD:

git checkout feature

git rebase main

git commit -m “git rebase” .

git pull

git push

When there are merge conflicts

simply fix the merge conflicts, then:

eventually you’ll be done with the rebase, then do


git status

to see what the next steps are.

Sequelize Belongs to Many

Belongs-To-Many associations

Belongs-To-Many associations are used to connect sources with multiple targets. Furthermore the targets can also have connections to multiple sources.

This will create a new model called UserProject with the equivalent foreign keys projectId and userId. Whether the attributes are camelcase or not depends on the two models joined by the table (in this case User and Project).

Defining through is required. Sequelize would previously attempt to autogenerate names but that would not always lead to the most logical setups.

This will add methods

  • getUsers
  • setUsers
  • addUser
  • addUsers

to Project, and

  • getProjects
  • setProjects
  • addProject
  • addProjects

to User

Similarly,

This will add methods

  • getBuildings
  • setBuildings
  • addBuilding
  • addBuildings

to User

like this:

There are also remove version of the generated methods like so:

  • removeBuilding
  • removeBuildings

Spread Syntax in JS

ref –
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax

Literal Objects

Arrays

Spread in Array Literals

[“head”, “shoulders”, “knees”, “and”, “toes”]

Spread in Object Literals

Adding flutter to native iOS

ref –

  • https://blog.codemagic.io/how-to-add-flutter-modules-to-native-ios-project-and-test-it-on-codemagic/
  • https://www.programmersought.com/article/24365560827/

Create an iOS native project

First we create a native iOS project.
click on tab option iOS, select App.

Create a text Welcome, and a button.

Right click on the start button and let’s implement a handler of the event touch up inside
Open up a side window and make sure ViewController.swift is open next to our Main.storyboard. Your can literally drag the event handler into ViewController.swiftConnect a button handler like so:

ViewController.swift

(your directory)/BMI_Calculator/BMItest/AppDelegate.swift

Save the project.

create folder bmi_calculator in a directory
copy and paste the iOS native project we just created into this folder.

Creating Flutter Module

Make sure you are in bmi_calculator folder.

Let’s make sure our app runs correctly by double clicking on .xcodeproj file and running the app.

This screen will later be used and appear in our iOS project.

Integrating Flutter module to native iOS

cd into the previous created BMI_calculator and create a pod file:

pod init

You’ll have a directory like so:

bmi_calculator/
├── bmi_flutter/
│ └── .ios/
│ └── Flutter/
│ └── podhelper.rb
└── BMI Calculator/
└── Podfile

In the Podfile:

flutter_application_path = ‘../bmi_flutter’
This is so that in your xcode project, it will go one directory up into bmi_calculator, and look for bmi_flutter.
load File.join(flutter_application_path, ‘.ios’, ‘Flutter’, ‘podhelper.rb’)
Once it finds bmi_flutter folder, it will go into folder .ios, folder Flutter, and finally access the podhelper.rb file

Now run pod install in BMI_calculator.

Make sure you see the log messages where it says installing flutter…etc:


Downloading dependencies
Installing Flutter (1.0.0)
Installing FlutterPluginRegistrant (0.0.1)
Installing my_flutter (0.0.1)

Now, reopen the project using the file with .xcworkspace extension.

You’ll see some warnings about converting it to Swift. Go ahead and do that.

Also be sure that your provisioning is correct.

Now make sure you press run and it should work on your simulator.

Now, when you click on the start button, you’ll see Flutter demo app come up.

Issues

If you get errors that says can’t find Flutter for your header files, make sure you do a clean build and then build in your xCode.

Using https to do requests in NODE JS

https://www.twilio.com/blog/2017/08/http-requests-in-node-js.html