Skip to content

Instantly share code, notes, and snippets.

Avatar

TSH code sharing tsh-code

View GitHub Profile
View throttledQueue.ts
import { Chime } from "@aws-sdk/client-chime";
const throttledQueue = require("throttled-queue");
const queue = throttledQueue(10, 1000, true);
const chimeClient = new Chime(chimeConfig);
async createAppInstanceUser(userName: string, appInstanceArn: string) {
const newUser = await this.queue(() =>
this.client.createAppInstanceUser({
AppInstanceArn: appInstanceArn,
View createChimeUsers.ts
async createChimeUsers() {
const tickets = await this.ticketsRepository.getTicketsForChatUsersCreation(150);
if (!tickets.length) return;
await this.chimeService.batchCreateChatUser(tickets);
}
View scheduleJob.ts
import * as schedule from "node-schedule";
schedule.scheduleJob("*/1 * * * *", async () => {
if (cronScheduleRepository.isScheduleInProgress(CronJobType.CREATE_CHAT_USERS)) {
return;
}
cronScheduleRepository.setScheduleInProgress(CronJobType.CREATE_CHAT_USERS, true);
await createChimeUsers();
cronScheduleRepository.setScheduleInProgress(CronJobType.CREATE_CHAT_USERS, false);
@tsh-code
tsh-code / snowflake-example-2.sql
Created Jul 27, 2022
Snowflake clone example
View snowflake-example-2.sql
CREATE OR REPLACE TABLE <STAGE_SCHEMA>.TABLE_A_CLONE CLONE <PROD_SCHEMA>.TABLE_A
View snowflake-example-1.sql
select
src:device_type::string as device_type
from json_table;
View index.html.twig
{% extends 'base.html.twig' %}
{% block javascripts %}
{{ parent() }}
<script src="{{ asset('js/index.js') }}"></script>
<script>
displayError({{ type }});
</script>
{% endblock %}
View base.html.twig
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
{% block stylesheets %}
<link rel="stylesheet" type="text/css" href="{{ asset('css/app.css') }}">
{% endblock %}
</head>
View IndexController.php
<?php
declare(strict_types=1);
namespace App\Controller;
class IndexController extends AbstractController
{
public function home(Request $request): Response
{
View error.js
var object = document.body;
function displayError(name) {
var alert = document.createElement('DIV');
object.append(alert);
// ...
}
View index.css
body {
background-color: #000;
}