Skip to content

Instantly share code, notes, and snippets.

View saniyathossain's full-sized avatar

Saniyat Hossain saniyathossain

View GitHub Profile
@saniyathossain
saniyathossain / postman-pre-request.js
Created May 6, 2020 09:50 — forked from bcnzer/postman-pre-request.js
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
@saniyathossain
saniyathossain / DataTable.vue
Created June 29, 2020 09:49 — forked from yajra/DataTable.vue
VueJS DataTables Snippets with Delete Button Component
<template>
<table>
<thead>
<tr>
<th v-for="column in parameters.columns" v-html="title(column)"></th>
</tr>
</thead>
<tfoot v-if="footer">
<tr>
<th v-for="column in parameters.columns" v-html="column.footer"></th>
@saniyathossain
saniyathossain / AppServiceProvider.php
Created July 11, 2020 07:04 — forked from simonhamp/AppServiceProvider.php
A pageable Collection implementation for Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()
@saniyathossain
saniyathossain / Dockerfile
Created September 13, 2020 09:20 — forked from BretFisher/Dockerfile
WIP sample Laravel php_fpm plus nginx plus supervisor Docker setup with npm, composer, bower, and more
FROM yourdockername/base-php-nginx:latest AS build
# BUILD STAGE
# the primary reason we have two build stages is so SSH key of private repo's will never
# be in final image
# COPY IN BUILD SSH KEY
# It won't be copied to final image
# add this build arg to compose file
ARG BUILDKEY
RUN if [ -z "$BUILDKEY" ]; then echo "BUILDKEY SSH NOT SET - ERROR"; exit 1; else : ; fi
Can I Remove MySQL Binary Log Yes, as long as the data is replicated to Slave server, it’s safe to remove the file. It’s recommend only remove MySQL Binary Log older than 1 month.
Besides, if Recovery of data is the main concern, it’s recommend to archive MySQL Binary Log.
There are several ways to remove or clean up MySQL Binary Log, it’s not recommend to clean up the file manually, manually means running the remove command.
Remove MySQL Binary Log with RESET MASTER Statement Reset Master statement is uses for new database start up during replication for Master and Slave server. This statement can be used to remove all Binary Log.
To clean up Binary Log on Master Server
@saniyathossain
saniyathossain / main.go
Created October 25, 2020 18:43 — forked from retgits/main.go
Get the current date in Go
// Original source: https://gistpages.com/posts/go-lang-get-current-date
// Go playground: https://play.golang.org/p/gBO8rdKI6UF
// time.Format should use the layout, Mon Jan 2 15:04:05 MST 2006 to show the pattern
package main
import (
"fmt"
"time"
)
@saniyathossain
saniyathossain / ValidGmailAddress.php
Created December 1, 2020 04:47 — forked from m1guelpf/ValidGmailAddress.php
A Laravel rule to ensure Gmail emails actually exist
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class ValidGmailAddress implements Rule
{
/**
* Determine if the validation rule passes.
@saniyathossain
saniyathossain / stream_file.php
Created January 2, 2021 08:26 — forked from fideloper/stream_file.php
Stream file from S3 to browser, assume Laravel Filesystem usage
<?php
/*************************************************************************
* Get File Information
*/
// Assuming these come from some data source in your app
$s3FileKey = 's3/key/path/to/file.ext';
$fileName = 'file.ext';
@saniyathossain
saniyathossain / axios-catch-error.js
Created January 9, 2021 17:01 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
DROP TABLE IF EXISTS `things`;
CREATE TABLE `things` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nbr` int(11) NOT NULL,
`thing` varchar(255) NOT NULL,
`createdAt` datetime NOT NULL DEFAULT NOW(),
`updatedAt` datetime NOT NULL DEFAULT NOW() ON UPDATE NOW(),
PRIMARY KEY (`id`),
UNIQUE KEY `nbr_unique` (`nbr`)