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 { DatabaseError } from "pg"; | |
import { DatabaseErrorCode } from "./errors"; | |
/** | |
* Higher order function with fine-grained error handling. | |
*/ | |
export async function withErrorHandling<T>( | |
fn: () => Promise<T>, | |
onError: Record<string, (error: PgDatabaseError) => void>, | |
) { |
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
/** | |
* Database (PostgreSQL) error codes. | |
*/ | |
export const DatabaseErrorCode = { | |
SuccessfulCompletion: "00000", | |
Warning: "01000", | |
DynamicResultSetsReturned: "0100C", | |
ImplicitZeroBitPadding: "01008", | |
NullValueEliminatedInSetFunction: "01003", | |
PrivilegeNotGranted: "01007", |
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
GET influencers/_search | |
{ | |
"size": 0, | |
"aggregations": { | |
"influencers": { | |
"nested": { | |
"path": "interests" | |
}, | |
"aggs": { | |
"names": { |
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
// main app | |
"repositories" : [ | |
{ | |
"type": "package", | |
"package": { | |
"name": "grininc/platform-shared", | |
"version": "dev-master", | |
"source": { | |
"url": "git://github.com/grininc/platform-shared.git", | |
"type": "git", |
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
# Set AWS credentials and S3 paramters | |
AWS_KEY="" | |
AWS_SECRET="" | |
S3_BUCKET="" | |
S3_BUCKET_PATH="/" | |
S3_ACL="x-amz-acl:private" | |
function s3Upload | |
{ | |
path=$1 |
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
// the parent, avoid clicks inside this element | |
const parent = document.getElementById('parent'); | |
window.addEventListener('click', e => { | |
let elem = e.target; | |
// loop through the target's parent nodes to see if it matches | |
for ( ; elem && elem !== document; elem = elem.parentNode ) { | |
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
.checkbox { | |
height: 40px; | |
width: 40px; | |
outline: none; | |
cursor: default; | |
border: 0; | |
-webkit-appearance: none; | |
-moz-appearance: none; | |
appearance: none; | |
} |
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 | |
// get interval | |
// format of $datetime is "Y-m-d H:i:s" | |
$interval = (new \DateTime("now"))->diff(new \DateTime($datetime)); | |
// get specific times | |
list($days, $hours, $minutes) = explode(" ", $interval->format("%d %h %i")); |
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
FROM php:5.6-fpm | |
RUN apt-get update && apt-get install -y git curl | |
RUN docker-php-ext-install -j$(nproc) pdo_mysql | |
RUN docker-php-ext-install -j$(nproc) mbstring | |
RUN docker-php-ext-install -j$(nproc) tokenizer | |
RUN curl -sS "https://getcomposer.org/installer" | php | |
RUN chmod a+x composer.phar && mv composer.phar /usr/local/bin/composer |
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
// form validation loaded from config | |
$('.ui.form').each(function(index){ | |
var config = $(this).data('config'); | |
if(config !== undefined) { | |
$(this).prepend('<div class="ui icon error message" id="form-errors"></div>'); | |
var settings = APP.config.validation; | |
config.split('.').forEach(function(el, i, arr){ |
NewerOlder