Skip to content

Instantly share code, notes, and snippets.

View smddzcy's full-sized avatar

Samed Düzçay smddzcy

View GitHub Profile
[mysqld]
port = 3306
max_allowed_packet = 256M
max_connect_errors = 1000000
skip_external_locking
skip_name_resolve
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 0
@smddzcy
smddzcy / git-repo-ssh.sh
Created April 21, 2020 10:41
Git repo-specific SSH keys
git config core.sshCommand "ssh -i ~/.ssh/smd-dev1 -F /dev/null"
@smddzcy
smddzcy / mail-validate.js
Created March 23, 2020 20:21
Validate bulk mail list using NPM package `email-deep-validator`.
const EmailValidator = require('email-deep-validator');
const path = require('path');
const fs = require('fs');
const throat = require('throat');
const emailValidator = new EmailValidator();
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
const retry = async (fn, retryCount = 2, intervalMs = 500, originalError = null) => {
@smddzcy
smddzcy / wildcard-ssl-certbot.sh
Created November 12, 2019 11:49
Wildcard SSL with Certbot
sudo certbot certonly -manual --email "[email protected]" --server "https://acme-v02.api.letsencrypt.org/directory" --agree-tos -d "*.acme.inc"
@smddzcy
smddzcy / react-transition-group-utils.scss
Created November 6, 2019 15:55
react-transition-group SASS Mixin
@mixin transition($childClasses, $enter, $normal, $exit, $transition, $transitionExit: null) {
@if not ($transitionExit) {
$transitionExit: $transition;
}
$split-values: str-split($childClasses, ", ");
@each $childClass in $split-values {
&-enter #{$childClass}, &-appear #{$childClass} {
@include list($enter);
}
@smddzcy
smddzcy / gist:4ccd5051190a9505f09c02ae3025a5c8
Created October 20, 2019 22:54
Get .crt and .key from .pfx
openssl pkcs12 -in cert.pfx -clcerts -out cert.txt -nodes
# open txt and get certificate + key
@smddzcy
smddzcy / gist:b29b8ebb474fc9aad494b69e38740859
Created October 20, 2019 22:34
Set IBM COS (Cloud Object Storage) bucket CORS policy
Link: https://cloud.ibm.com/docs/services/cloud-object-storage/cli?topic=cloud-object-storage-curl#curl-list-buckets
Policy to add: <CORSConfiguration><CORSRule><AllowedMethod>PUT</AllowedMethod><AllowedMethod>POST</AllowedMethod><AllowedMethod>DELETE</AllowedMethod><AllowedMethod>GET</AllowedMethod><AllowedOrigin>*</AllowedOrigin><AllowedHeader>*</AllowedHeader></CORSRule></CORSConfiguration>
@smddzcy
smddzcy / install-node.sh
Last active August 6, 2019 00:35
Install Node LTS 10 on Centos
sudo su
curl -sL https://rpm.nodesource.com/setup_10.x | bash -
sudo yum clean all && sudo yum makecache fast
sudo yum install -y gcc-c++ make
sudo yum install -y nodejs
@smddzcy
smddzcy / _schema.js
Last active May 14, 2019 20:35
Mongoose-like ORM for Cosmos DB SQL API
const _ = require('lodash');
const Redis = require('ioredis');
const sqlBuilder = require('mongo-sql'); // from https://github.com/smddzcy/mongo-sql#master
const uuid = require('uuid');
const throat = require('throat');
const DbError = require('../error/dbError');
const cast = require('../cast');
const client = new CosmosClient({ endpoint: '...', key: '...' });
const database = client.database('...');
@smddzcy
smddzcy / infinite-swipe-react-swipeable.js
Created December 7, 2018 13:03
Infinite swipe using react-swipeable
onColorSwipe = (e, dx, dy, absX, absY, v) => {
const h = this.colorScroller.scrollHeight;
this.setState(state => {
const top = state.colorScrollerTop + state.colorScrollerDy;
if (-top > h * 4 / 5) { // almost at the end
return { colorScrollerTop: state.colorScrollerTop + h / 3, colorScrollerDy: -dy };
}
if (-top < h / 5) { // almost at the beginning
return { colorScrollerTop: state.colorScrollerTop - h / 3, colorScrollerDy: -dy };
}