Skip to content

Instantly share code, notes, and snippets.

View basyusuf's full-sized avatar
Focusing

Yusuf Baş basyusuf

Focusing
  • Turkey
View GitHub Profile
@basyusuf
basyusuf / jsdoc.config.json
Created November 25, 2020 19:51
JSDoc Configuration
{
"source":{
"include":["src"],
"includePattern":".js$",
"excludePattern":"(node_modules/|docs)"
},
"plugins":["plugins/markdown"],
"templates":{
"cleverLinks":true,
"monospaceLinks":true
@basyusuf
basyusuf / jsdocExampleOne.js
Created November 25, 2020 20:11
JSDoc example
/** @function kullaniciOlustur
* @param {string} isim - Kullanıcı ismi
* @param {string} soyisim - Kullanıcı soyismi
* @param {number} yas - Kullanıcı yaşı
* @return Kullanıcı oluşturuldu
* @see https://github.com/basyusuf
*/
const kullaniciOlustur = (isim, soyisim, yas) => {
console.log(isim);
console.log(soyisim);
@basyusuf
basyusuf / puppeteer_serverless.yml
Created December 5, 2020 17:40
puppeteer_serverless.yml
service: screenshotproject
frameworkVersion: '2'
custom:
bucket: screenshot-buckets-test # Sizin oluşturduğunuz bucket'ın ismi
provider:
name: aws
runtime: nodejs12.x
region: eu-central-1
iamRoleStatements:
- Effect: Allow
const chromium = require('chrome-aws-lambda');
const AWS = require('aws-sdk');
const BUCKET_NAME = "screenshot-buckets-test";
AWS.config.region = 'eu-central-1';
@basyusuf
basyusuf / puppeteer_func_p2.js
Created December 5, 2020 17:56
Helper Func S3
const putObjectToS3 = async(key, data) => {
console.info("Starting PutObject S3");
let s3Bucket = new AWS.S3();
let params = {
Bucket: BUCKET_NAME,
Key: key,
Body: data,
ContentEncoding: 'base64',
ContentType: 'image/jpeg',
ACL: 'public-read'
@basyusuf
basyusuf / puppeteer_func_p3.js
Created December 5, 2020 17:58
Main Function
exports.main = async (event, context, callback) => {
console.info("Request Event:", event);
let browser = null;
let responseBody = {};
let bucketDomain = "https://screenshot-buckets-test.s3.eu-central-1.amazonaws.com/";
let imageUniqueName;
const parsed_body = JSON.parse(event.body);
const PAGE_URL = parsed_body.page_url;
try {
@basyusuf
basyusuf / turkey-geomap.json
Created January 7, 2021 13:23
Türkiye il ve ilçe koordinatları
[
{
"city": "Istanbul",
"lat": "41.0100",
"lng": "28.9603",
"admin_name": "İstanbul",
"capital": "admin",
"population": "15154000",
"population_proper": "15029231"
},
@basyusuf
basyusuf / exportDynamoDB.js
Created January 8, 2021 08:22
Export all DynamoDB items
const AWS = require('aws-sdk');
AWS.config.update({region:'eu-central-1'});
const fs = require('fs');
const TABLE_NAME = "YOURTABLENAME";
const docClient = new AWS.DynamoDB.DocumentClient({
"sslEnabled": false,
"paramValidation": false,
"convertResponseTypes": false,
"convertEmptyValues": true
@basyusuf
basyusuf / business_logic_bank.js
Created March 3, 2021 23:23
Business Logic Bank Example
let transferAmount = body.amount;
let currentBalance = user.getBalance();
if (transferAmount <= currentBalance) {
// Complete the transfer
} else {
// Unsuccessful transfer. Blocked
}
@basyusuf
basyusuf / bad_singleton.ts
Created March 10, 2021 22:34
Bad Singleton Example
class Redis {
private id: number;
private base_url: string;
private port: number;
constructor(base_url: string, port: number = 6379) {
this.base_url = base_url;
this.port = port;
this.id = new Date().getTime();
}
connect() {