Skip to content

Instantly share code, notes, and snippets.

View tsh-code's full-sized avatar

TSH code sharing tsh-code

View GitHub Profile
ocr_notebook_map = {
"easyocr": "easyocr.ipynb",
"pytesseract": "pytesseract.ipynb",
"kerasocr": "kerasocr.ipynb",
"paddle": "paddle.ipynb",
"tensorflow": "tensorflow.ipynb"
}
def run_ocr(CONFIG):
if CONFIG.get("skip_ocr_processing", False):
config = {
"directory": "OCR/Invoices1",
"ocr_library": "pytesseract",
"output_file": "results-bc-without.txt",
"statistics_file": "statistics-bc-without.txt",
"apply_cropping": False,
"resize_to_fhd": True,
"deskew_image": True,
"threshold_method": "niblack",
"skip_ocr_processing": False,
<?php
// 1.
$isUserModerator = $user->isType(‘moderator’);
class User {
// . . .
public function isType(string $type): bool
{
<?php
$type = $user->type(‘moderator’);
<?php
class Generator {
public function generateJsonFile(array $data): void;
{
$content = json_encode($data);
header(‘Content-Type: application/json`);
header(‘Content-Disposition: attachment; filename="data.json”`);
ob_start();
<?php
class Generator {
private const JSON_TYPE = ‘application/json’;
private const CSV_TYPE = ‘text/csv’;
private const JSON_EXT = ‘json’;
private const CSV_EXT = ‘csv’;
private function disposition(
string $filename,
<?php
class Generator {
// . . .
public function generate(string $filename, array $data, string $fileType): void {
$content = $this->generateContent($data, $fileType);
$this->disposition($filename, $content, $fileType);
}
}
<?php
class JsonResponseGenerator {
const CONTENT_TYPE = 'application/json';
const FILENAME = 'data.json';
public function generate(array $data): void
{
$content = json_encode($data);
if ($content === false) {
@tsh-code
tsh-code / button.tsx
Created September 22, 2023 10:08
A/B Testing - Button Component
import React from "react";
import { useExperiment } from "./useExperiment";
export const CallToActionButton = ({ onClick }) => {
const isExperimentEnabled = useExperiment("EXP_CALL_TO_ACTION_BUTTON_COLOR");
return (
<button type="button" onClick={onClick} style={{ backgroundColor: isExperimentEnabled ? "green" : "yellow" }}>
Call to Action
</button>
@tsh-code
tsh-code / getServerSideProps.ts
Created September 22, 2023 10:01
A/B Testing - Experiment Assignment
import { GetServerSideProps } from "next";
import { Variant } from "unleash-client";
import { UnleashClient } from "./unleash.client";
type Props = { experiments: Record<string, Variant> };
export const getServerSideProps: GetServerSideProps<Props> = async ({ req }) => {
const client = await UnleashClient.getInstance();
return {