Why use Sequelize? Sometimes you want your team to use an ORM. Often you need to run migrations. Sequelize provides ORM features and a much needed migrations library that allows us to create producible and version controlled database schemas. Setup your project Step 1: Create an npm project in your desired directory $ npm init…
All posts by theptrk
How does sequelize pluralize?
If you use .sync with sequlize and have a model name like User, your database ends up with a table called Users. More clearly, when you use the sequelize-cli model generator the generated file will show this pluralized table. Here is the code: (link) What is Utils? * Note Sequelize has a directory called Utils AND a file…
Postgres timestamp with timezone – “timestamptz”
Postgres can store your “timestamp with timezone” or “timestamp without timezone”.If you don’t specify either, it will default to “timestamp without timezone” Which one should you use? TLDR: “timestamps with time zones” Whats the problem living life without timezones? Say you have two users in two different timezones – one in California and one in…
Using CAShapeLayer to draw a circle
UIViews are like Ogres, which are like onions – they have layers. Source: Documentation More accurately, UIView has a single layer property that can have infinite sublayers. UIView’s have layers Lets draw a circle. First create a UIView and a CAShapeLayer: let myView = UIView() let myLayer = CAShapeLayer() Layers have a path UIBezierPath makes drawing shapes…
iOS Application Lifecycle – UIKit basics
iOS applications are all about cycles This is because the iOS applications are richly interactive when it comes to user input and much of your programming with UIKit will be delegate oriented. Knowing the many different “cycles” of the device and application will be illuminating for your development. States of the UIKit App Cycle * These are the…
iOS without storyboard
Why? Programmatically/Code or NIB based layouts are a much better fit for projects that use version control (see merge conflicts) and make it much easier to reuse views. If you are deciding not to use storyboards, you will need to manually set your application window to your desired UIWindow Prerequisites: – Delete Main Interface from Deployment…
Forgetting to set translatesAutoresizingMaskIntoConstraints to false
UIKit on iOS is great! There are tons of tools and often this can supercharge your productivity for getting a prototype out into the world. Additionally, working with AutoLayout programmatically can be great if you avoid these rookie mistakes. Rookie Mistake 1: It hurts when you spend hours dealing with the rookie mistake of forgetting to…
Delete files by filename with “find”
When you upload photos multiple times, the computer can start numbering the photos. IMG_A becomes IMG_A 1 and IMG_A 2 and IMG_A 3. Using a wildcard * and specifying the ending space and number will help you select the files. For example: Find all the files that end in “space”1.JPG find -name ‘* 1.JPG’ * Have a look at the…
Setting environment variables
How to see and set your environment variables Print all your current environment variables with $ printenv See a the value for a specific variable with echo $ printenv <YOUR_VARIABLE> or $ echo $<YOUR_VARIABLE> For example: $ printenv MY_API_KEY or $ echo $MY_API_KEY How do I set the variable temporarily? This will set your variable for ONLY…
Postgres tutorial – installing with brew + basics
Step 1: Install postgres brew install postgres Step 2: Start postgres server brew services start postgresql Step 3: Create a database Lets call our database “book” $ createdb book Step 4: open the psql shell List all databases in terminal with: $ psql –list Adding the name of the db after the command psql will open…