This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable, OnModuleDestroy, OnModuleInit, Type } from '@nestjs/common'; | |
import { PrismaClient, Prisma } from '@prisma/client'; | |
const existsExtension = Prisma.defineExtension({ | |
name: 'exists-extension', | |
model: { | |
$allModels: { | |
async exists<T>(this: T, where: Prisma.Args<T, 'findFirst'>['where']): Promise<boolean> { | |
const context = Prisma.getExtensionContext(this); | |
const result = await (context as any).findFirst({ where }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor() { | |
super() | |
const ext = Prisma.defineExtension((client) => | |
client.$extends({ | |
name: 'webinarAfterCreate', | |
query: { | |
webinar: { | |
async create({ args, query }) { | |
console.log('webinarAfterCreate', args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common' | |
import { PrismaClient } from '@prisma/client' | |
import { faker } from '@faker-js/faker' | |
@Injectable() | |
export class DatabaseService | |
extends PrismaClient | |
implements OnModuleInit, OnModuleDestroy | |
{ | |
constructor() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common' | |
import { PrismaClient } from '@prisma/client' | |
import { faker } from '@faker-js/faker' // 샘플 문자열 생성 용도 | |
@Injectable() | |
export class DatabaseService | |
extends getExtendedClient() | |
implements OnModuleInit, OnModuleDestroy | |
{ | |
async onModuleInit() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# linkwarden > Settings > Access Token | |
TOKEN="" | |
HOST_URL="" | |
COLLECTION_ID="" | |
# collection where invalid urls go | |
INVALID_COLLECTION_ID="" | |
# some notes | |
# 1. "while read -r" is required to preserve escape from compact output from jq | |
# 2. NEW_URL can make jq breaking if NEW_URL itself have double-qoutations (which is not escaped) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TARGET_URL="$1" | |
BASE_URL=$(dirname $TARGET_URL) | |
NEXT_URL="go first" | |
until [ -z "$NEXT_URL" ] | |
do | |
w3m -I cp949 -O cp949 -cols 72 -dump $TARGET_URL | awk 'BEGIN {sw=""} /\[목록보기\]/ {sw=""} {if (sw) print} /댓글 부분으로/ {sw="ok"}' | |
NEXT_URL=$(w3m -dump_source $TARGET_URL | grep -m 1 "윗글" | awk -F\' '{print $2}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FIFO="/tmp/mpvpipe" | |
TARGET=$1 | |
if [ "x--" = "x$TARGET" ]; then | |
TARGET=$2 | |
fi | |
PID=$(fuser $FIFO 2> /dev/null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var request = require('request'); | |
var base64 = require('base64-stream'); | |
var JSONStream = require('JSONStream'); | |
var visionArgs = {key: fs.readFileSync('vision.key')}; | |
var visionUrl = 'https://vision.googleapis.com/v1/images:annotate'; | |
var reader = process.stdin.pipe(base64.encode()); | |
var writer = request.post({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$epoch = microtime(true); | |
function times(int $a) { | |
global $epoch; | |
$i = 0; | |
while (++$i <= $a) { | |
//sleep(1); | |
var_dump(microtime(true) - $epoch); |
NewerOlder