This file contains 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
describe('ProductService', () => { | |
let service: ProductService | |
let servicMock: Partial<ProductService> | |
beforeEach(async () => { | |
const module: TestingModule = await Test.createTestingModule({ | |
imports: [AppModule], | |
}).compile() | |
service = module.get<ProductService>(ProductService) |
This file contains 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
{ | |
"id": "msg_01TioynCv5SbDGXsLLUnUPTL", | |
"type": "message", | |
"role": "assistant", | |
"model": "claude-3-5-sonnet-20240620", | |
"content": [ | |
{ | |
"type": "text", | |
"text": "AN AMAZING DESCRIPTION" | |
} |
This file contains 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 Anthropic from '@anthropic-ai/sdk' | |
@Injectable() | |
export class ProductService { | |
@Inject() configService: ConfigService | |
createProductDescription(productName: string){ | |
const anthropicConfig = this.configService.get<AntrhopicConfig>('anthropic') | |
const anthropic = new Anthropic({ apiKey: anthropicConfig.secret }) | |
This file contains 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
const nums = [17, 1, 2, 3, -1] | |
const obj = (x) => { | |
return {initial: x, square: x*x, positive: Math.sign(x) > 0 ? true : false} | |
} | |
Array.prototype.myMap = function(cb){ | |
const output = [] | |
for(let i = 0; i<this.length; i++){ | |
output.push(cb(this[i])) |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>UFA Interactive SVG</title> | |
<link rel="icon" type="image/x-icon" href="/favicon.ico" /> | |
<link rel="apple-touch-icon" href="/apple-touch-icon.png" /> | |
<style> |
This file contains 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
let imagePath: string = '' | |
const resp = await RNFetchBlob.config({ | |
fileCache: true, | |
}).fetch('GET', url) | |
imagePath = resp.path() | |
const base64 = await resp.readFile('base64') | |
fs.unlink(imagePath) |
This file contains 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
<WebView | |
originWhitelist={['*']} | |
source={{ html: script }} | |
javaScriptEnabled={true} | |
onMessage={(event) => { | |
if (!event.nativeEvent?.data) { | |
return; | |
} | |
console.log(event.nativeEvent.data); | |
}} |
This file contains 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
const script = ` | |
<script> | |
function get_average_rgb(img) { | |
var context = document.createElement('canvas').getContext('2d'); | |
var src = img; | |
img = new Image; | |
img.setAttribute('crossOrigin', ''); | |
img.src = "data:image/png;base64," + src; | |
img.onload = function () { | |
context.imageSmoothingEnabled = true; |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Document</title> | |
<style> | |
.slider { |
This file contains 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, NestInterceptor, ExecutionContext, CallHandler, Inject, Logger} from '@nestjs/common' | |
import {map, Observable, tap} from 'rxjs' | |
import {RedisService} from './redis.service' | |
@Injectable() | |
export class CacheInterceptor implements NestInterceptor { | |
@Inject() redisService: RedisService | |
async intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<any>> { | |
if (process.env.NODE_ENV.includes('development')) { |
NewerOlder