Skip to content

Instantly share code, notes, and snippets.

View tsh-code's full-sized avatar

TSH code sharing tsh-code

View GitHub Profile
@tsh-code
tsh-code / ngProjectDetails.sh
Created April 20, 2020 14:30 — forked from jrybinski/ngProjectDetails.sh
Print out details of angular project. Used for comparing bundle size with project details.
getFilesOfType() {
find . -name "$1" -not -path "./node_modules/*" -not -path "./dist/*" -not -path "./reports/*"
}
getEs5JSBuildFiles() {
du -chk ./dist/*es5*.js | grep total
}
getEs2015JSBuildFiles() {
du -chk ./dist/*es2015*.js | grep total
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"mainEntityOfPage": "https://www.theverge.com/2018/8/27/17785594/apple-iphone-xs-september-launch-three-new-devices-rumors",
"headline": "Apple to launch three new iPhones, Watch with larger screen, updated iPad Pros, says Bloomberg",
"description": "Apple is expected to launch three new iPhones in September, according to the latest rumors and supply chain leaks. A new report from Bloomberg says there’ll be an upgraded iPhone X, a version with a larger screen, and a cheaper handset with colorful variants and an LCD display. ",
"speakable": {
"@type": "SpeakableSpecification",
"xpath": [
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@id": "https://www.apple.com/#organization",
"@type": "Organization",
"name": "Apple",
"url": "https://www.apple.com/",
"logo": "https://www.apple.com/ac/structured-data/images/knowledge_graph_logo.png?201709101434",
"contactPoint": [
{
@tsh-code
tsh-code / api.ts
Created October 3, 2019 07:23 — forked from barograf/api.ts
API service
import * as awilix from "awilix";
import * as dotenv from "dotenv";
import * as serverless from "serverless-http";
import DynamoDbStorage from "../shared/storage/dynamoDb";
import createContainer from "./container";
import Server from "./server/server";
dotenv.config();
const container = createContainer({
@tsh-code
tsh-code / producer.ts
Created October 3, 2019 07:23 — forked from barograf/producer.ts
Producer service
import * as awilix from "awilix";
import * as dotenv from "dotenv";
import DynamoDbStorage from "../shared/storage/dynamoDb";
import TranslationsStorage from "../shared/translations/translations";
import createContainer from "./container";
import GoogleSheets from "./google/sheets";
import ITransformer from "./transformer/transformer";
dotenv.config();
@tsh-code
tsh-code / serverless.yml
Created October 3, 2019 07:23 — forked from barograf/serverless.yml
Translations service config
service: serverless-translations
plugins:
- serverless-plugin-typescript
provider:
name: aws
runtime: nodejs8.10
stage: dev
region: us-east-1
@tsh-code
tsh-code / resultobjectusage.php
Created June 10, 2019 09:44 — forked from szyku/resultobjectusage.php
Result Object Usage
<?php
$operation = File::openForRead(join(DIRECTORY_SEPARATOR, [__DIR__, 'credit_cards.txt']));
if ($operation->isSuccessful) {
return CreditCardNumberExtractor::createFromHandler($operation->payload);
}
/* ... */
@tsh-code
tsh-code / fopenexample.php
Created June 10, 2019 09:40 — forked from szyku/fopenexample.php
fopen example
<?php
$handler = @fopen(join(DIRECTORY_SEPARATOR, [__DIR__, 'credit_cards.txt']), "r");
if ($handler) {
return CreditCardNumberExtractor::createFromHandler($handler);
}
/* ... */
@tsh-code
tsh-code / resultobject.php
Created June 10, 2019 09:40 — forked from szyku/resultobject.php
Result Object
<?php
final class ResultObject
{
public $isSuccessful;
public $payload = null;
private function __construct(bool $isSuccessful, $payload = null)
{
$this->isSuccessful = $isSuccessful;
$this->payload = $payload;
@tsh-code
tsh-code / exception3.php
Last active June 10, 2019 09:39 — forked from szyku/exception3.php
Better reason
<?php
if ($response->getStatusCode() >= 400) {
$code = $this->extractErrorCode($response->getBody());
switch ($code) {
case FailReasons::NO_TAGS:
$msg = 'The document has not enough signature tags';
break;
//...