Skip to content

Instantly share code, notes, and snippets.

BetterProgramming

Block or report user

Report or block BetterProgramming

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View nest6.js
@Post()
@UseInterceptors(
FileInterceptor('image', {
storage: diskStorage({
destination: './files',
filename: editFileName,
}),
fileFilter: imageFileFilter,
}),
)
View nest5.js
export const editFileName = (req, file, callback) => {
const name = file.originalname.split('.')[0];
const fileExtName = extname(file.originalname);
const randomName = Array(4)
.fill(null)
.map(() => Math.round(Math.random() * 16).toString(16))
.join('');
callback(null, `${name}-${randomName}${fileExtName}`);
};
View nest4.js
export const imageFileFilter = (req, file, callback) => {
if (!file.originalname.match(/\.(jpg|jpeg|png|gif)$/)) {
return callback(new Error('Only image files are allowed!'), false);
}
callback(null, true);
};
View nest3.js
@Post('multiple')
@UseInterceptors(
FilesInterceptor('image', 20, {
storage: diskStorage({
destination: './files',
filename: editFileName,
}),
fileFilter: imageFileFilter,
}),
)
View nest2.js
@Post()
@UseInterceptors(
FileInterceptor('image'),
)
async uploadedFile(@UploadedFile() file) {
const response = {
originalname: file.originalname,
filename: file.filename,
};
return response;
View nest1.js
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { MulterModule } from '@nestjs/platform-express';
@Module({
imports: [MulterModule.register({
dest: './files',
})],
controllers: [AppController],
})
View thing2.js
private fun startAnimate() {
compositeDisposable.add(Observable
.interval(0, 1, TimeUnit.SECONDS)
.flatMap {
return@flatMap Observable
.interval(0, 100, TimeUnit.MILLISECONDS)
.take(image.size.toLong())
}
.map { it.toInt() }
.doAfterNext { if (it == (image.size - 1)) control *= -1 }
View thing1.js
private fun startAnimate() {
RxJavaPlugins.setErrorHandler { /*Catch InterruptedException*/ }
compositeDisposable.add(Observable
.create<Int> { emitter ->
while (true) {
if (control == 1) {
for (x in 0 until image.size) {
emitter.onNext(x)
Thread.sleep(100)
}
View thing1.js
private fun startAnimate() {
RxJavaPlugins.setErrorHandler { /*Catch InterruptedException*/ }
compositeDisposable.add(Observable
.create<Int> { emitter ->
while (true) {
if (control == 1) {
for (x in 0 until image.size) {
emitter.onNext(x)
Thread.sleep(100)
}
View styles.scss
/* You can add global styles to this file, and also import other style files */
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
@import "./assets/bootstrap.min.css";
@import "./assets/bootstrap-theme.min.css";
body {
font-family: "Roboto", sans-serif;
margin: 0;
}
form {
mat-form-field {
You can’t perform that action at this time.