Skip to content

Instantly share code, notes, and snippets.

View 2color's full-sized avatar
🎁
Building

Daniel Norman 2color

🎁
Building
View GitHub Profile
# curl https://codeload.github.com/ORG/REPO/tar.gz/BRANCH
# tar -xz --strip=3 REPO-BRANCH/deployment-platforms/zeit-now/
curl https://codeload.github.com/prisma/prisma-examples/tar.gz/prisma2-deployment-zeit | tar -xz --strip=3 prisma-examples-prisma2-deployment-zeit/deployment-platforms/zeit-now/

ORM Patterns

In practice there are two common ORM patterns:

  • ActiveRecord: uses the model class to handle both business logic and database access.
  • DataMapper: a more complex approach which separates the in-memory objects from the database. Uses two class types:
    • Mapper: handles database access and mapping entities
    • Entities: in-memory representation with business logic

Some ORMs, like TypeORM support both patterns. Others like Sequelize support only ActiveRecord.

Failed calculateDatabaseSteps at 2019-12-18T10:35:02.979Z

RPC One-Liner

{"id":3,"jsonrpc":"2.0","method":"calculateDatabaseSteps","params":{"projectInfo":"","assumeToBeApplied":[{"stepType":"CreateModel","model":"User"},{"stepType":"CreateField","model":"User","field":"id","type":"String","arity":"required"},{"stepType":"CreateDirective","model":"User","field":"id","directive":"default"},{"stepType":"CreateDirectiveArgument","model":"User","field":"id","directive":"default","argument":"","value":"cuid()"},{"stepType":"CreateDirective","model":"User","field":"id","directive":"id"},{"stepType":"CreateDirective","model":"User","field":"id","directive":"unique"},{"stepType":"CreateField","model":"User","field":"email","type":"String","arity":"required"},{"stepType":"CreateDirective","model":"User","field":"email","directive":"unique"},{"stepType":"CreateField","model":"User","field":"name","type":"String","arity":"optional"},{"stepType":"CreateField","model":"User","field":"posts","type":"Post","arit

Failed calculateDatabaseSteps at 2019-12-17T17:44:16.463Z

RPC One-Liner

{"id":3,"jsonrpc":"2.0","method":"calculateDatabaseSteps","params":{"projectInfo":"","assumeToBeApplied":[{"stepType":"CreateModel","model":"User"},{"stepType":"CreateField","model":"User","field":"id","type":"String","arity":"required"},{"stepType":"CreateDirective","model":"User","field":"id","directive":"default"},{"stepType":"CreateDirectiveArgument","model":"User","field":"id","directive":"default","argument":"","value":"cuid()"},{"stepType":"CreateDirective","model":"User","field":"id","directive":"id"},{"stepType":"CreateField","model":"User","field":"email","type":"String","arity":"required"},{"stepType":"CreateDirective","model":"User","field":"email","directive":"unique"},{"stepType":"CreateField","model":"User","field":"name","type":"String","arity":"optional"}],"stepsToApply":[{"stepType":"CreateModel","model":"User"},{"stepType":"CreateField","model":"User","field":"id","type":"String","arity":"required"},{"stepT

Trigger cronjob manually

kubectl create job --from=cronjob/[CRONJOB] test-job-name

@2color
2color / publishReplay.js
Last active January 10, 2019 16:05
Example of how publishReplay works
// https://jsbin.com/gacexawuju/edit?js,console
//emit value every 1 second
const source = Rx.Observable.interval(1000).take(5);
const example = source
//side effects will be executed once
.do(() => console.log('Do Something!'))
//do nothing until connect() is called
// Cache the last 3 values
.publishReplay(3)
@2color
2color / defafultObjectProps.js
Created January 10, 2019 09:19
Default method parameters can access object properties
class Person {
constructor (name) {
this.name = name
this.defaultSalultation = 'Dr.'
}
sayHello (salutation = this.defaultSalultation) {
return `Hello ${salutation} ${this.name}`
}
}
{
"key": "%XeDqVs7hGP1g36xG+u8mCcy6yp+G4QrC25tO/8RmTzA=.sha256",
"value": {
"previous": "%7HOW+sn5+LqSn48AFkhHLUkLIVCpljzGbBoIo+P25wo=.sha256",
"author": "@QGXfP5kyNOnxhuf6+d9nSDPwSu55vjEdmKOecegeQso=.ed25519",
"sequence": 34,
"timestamp": 1543250630956,
"hash": "sha256",
"content": {
"type": "contact",
@2color
2color / README.md
Last active March 5, 2018 07:53 — forked from willejs/README.md
Moving Concourse Pipelines

Moving Concourse Pipelines

Intro

Currently concourse does not support moving pipelines between teams via fly CLI. There is an issue for that here

The only way to do this is to make a few changes in the DB.

If you run the statement below you will see that 6 tables have the team_id column.

concourse=> select table_name                                                                                                                                                                                                                                                                                                                                                       from INFORMATION_SCHEMA.COLUMNS                                                                                                                                                                                                                                                                   
@2color
2color / credentials-example.yaml
Last active January 31, 2018 13:28
Concourse Snippets
github-access-token: "......"
slack-notifications-webhook: http://hooks.slack.com.......
gcr-key: |
{
"type": "service_account",
"project_id": "myproject"
}
git-private-key: |-
-----BEGIN RSA PRIVATE KEY-----
...