Skip to content

Instantly share code, notes, and snippets.

@zarv1k
zarv1k / abstract-unique-validator.ts
Last active April 12, 2024 07:14
Unique Validator Example for NestJS
import { ValidationArguments, ValidatorConstraintInterface } from 'class-validator';
import { Connection, EntitySchema, FindConditions, ObjectType } from 'typeorm';
interface UniqueValidationArguments<E> extends ValidationArguments {
constraints: [
ObjectType<E> | EntitySchema<E> | string,
((validationArguments: ValidationArguments) => FindConditions<E>) | keyof E,
];
}
@mandx
mandx / cloud-image-region-transfer.sh
Created July 15, 2015 16:34
Script to copy a Rackspace server image from one data center (region) to another (by Andrew Howard)
#!/bin/bash
#
# Author: Andrew Howard
# This script will copy an server image from one region to another.
# BE AWARE: This will incur charges for the customer. These charges
# can be minimized by using ServiceNet for the download and by choosing
# to auto-delete the Cloud Files content once the transfer is complete.
# Even with these precautions, the customer will be charged for storage
# fees in Cloud Files (for a single month) and Cloud Images (destination).
# Note: To use ServiceNet, this script MUST be run on a Cloud Server
@hxgdzyuyi
hxgdzyuyi / backbone-mixin.js
Created September 6, 2012 08:21 — forked from dmitry/backbone-mixin.js
Merge backbone views (mixin pattern)
define('backbone', ['lib-underscore', 'lib-backbone'], function () {
Backbone.mixin = function (view, mixin, custom) {
if (custom) {
if (custom.events && mixin.events) {
mixin = _.clone(mixin)
_.defaults(custom.events, mixin.events)
}
_.extend(mixin, custom)
}
var source = view.prototype || view