Skip to content

Instantly share code, notes, and snippets.

@asciant
asciant / README.md
Created November 10, 2023 21:20
Seed with ts-node

Install the required packages:

pnpm install tsconfig-paths ts-node --save-dev

Update the package.json

"seed": "ts-node drizzle/seed.ts"
@asciant
asciant / drizzle.ts
Last active November 24, 2023 22:26
class-model.server.ts
// Class based abstraction layer for Drizzle (using nextjs)
import z from "zod";
import { db } from "@/lib/db";
import { validate } from "@/lib/validate";
import { model } from "@/drizzle/schema";
type NewModel = typeof model.$inferInsert;
type Model = typeof model.$inferSelect;
@asciant
asciant / shipitfile.js
Created December 1, 2019 02:32
Example file from tutorial
module.exports = shipit => {
require('shipit-deploy')(shipit);
require('shipit-shared')(shipit);
const appName = 'hello';
shipit.initConfig({
default: {
deployTo: '/home/deployer/example.com',
repositoryUrl: 'https://git-provider.tld/YOUR_GIT_USERNAME/YOUR_GIT_REPO_NAME.git',
@asciant
asciant / Diff.js
Created May 3, 2019 05:26
Diff.js
server.express.use(async (request, response, next) => {
if (!request.userId) return next();
const user = await db.query.user(
{ where: { id: request.userId } },
'{ id, permission, email, name }'
);
request.user = user;
next();
@asciant
asciant / git-feature-workflow.md
Last active May 6, 2019 01:30 — forked from gsamaras/git-feature-workflow.md
Git basics - a general workflow

There are many Git workflows out there, I heavily suggest also reading the atlassian.com [Git Workflow][article] article as there is more detail then presented here.

The two prevailing workflows are [Gitflow][gitflow] and [feature branches][feature]. IMHO, being more of a subscriber to continuous integration, I feel that the feature branch workflow is better suited.

When using Bash in the command line, it leaves a bit to be desired when it comes to awareness of state. I would suggest following these instructions on [setting up GIT Bash autocompletion][git-auto].

Basic branching

When working with a centralized workflow the concepts are simple, master represented the official history and is always deployable. With each now scope of work, aka feature, the developer is to create a new branch. For clarity, make sure to use descriptive names like transaction-fail-message or github-oauth for your branches.

@asciant
asciant / Angular.txt
Last active June 29, 2018 06:55
Angular
ng n MyApp --routing
cd MyApp
npm install --save '@angular/material' '@angular/cdk'
npm install --save '@angular/animations'
[In app.module.ts]
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
imports: [
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule,
@asciant
asciant / component.html
Last active January 2, 2017 05:53
Component
<div *ngFor="let item of data | async">
{{ item.data }}
</div>
@asciant
asciant / regex.ts
Created January 2, 2017 03:41
RegEx Validator angular
emailRegex = /^[a-z0-9!#$%&'+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-][a-z0-9])?(.a-z0-9?)*$/i;
registration : FormGroup;
constructor(r: FormBuilder, public http :Http){
this.registration = r.group({
'chosen_username' : [null, Validators.required],
'chosen_email' : [null, Validators.pattern(this.emailRegex)],
'chosen_password' : [null, Validators.required],
});
}
#!/bin/bash
while true;
do
i2cget -y 1 0x48 0x00 w |
awk '{printf("%.1f\n", (a=( \
(("0x"substr($1,5,2)substr($1,3,1))*0.0625)+0.1) \
)>128?a-256:a)}'