Skip to content

Instantly share code, notes, and snippets.

View canavci2016's full-sized avatar

Can Avci canavci2016

  • koç sistem
  • marmaris
View GitHub Profile
@canavci2016
canavci2016 / stack.js
Last active September 16, 2022 15:05
stack implementation (fifo) . data elements are retrieved from last to first
#include <iostream>
#include <stack>
template <class T>
class Node
{
private:
T data;
Node *prev;
#include <iostream>
#include <functional>
class Node
{
private:
int data;
Node *next;
@canavci2016
canavci2016 / index.ts
Last active September 9, 2022 21:46
type script boilerplate
interface User {
name: string;
id: number;
}
class UserAccount implements User {
name: string;
id: number;
constructor(name: string, id: number) {
@canavci2016
canavci2016 / README.MD
Last active September 8, 2022 14:39
nodejs style guide

Not: it is quoted from google javascript guide document

https://google.github.io/styleguide/jsguide.html

File name

File names must be all lowercase and may include underscores (_) or dashes (-), but no additional punctuation. Follow the convention that your project uses. Filenames’ extension must be .js. example: user-relations.js

Variable Names

@canavci2016
canavci2016 / binary.cpp
Last active September 3, 2022 14:33
searching algorithms
#include <iostream>
#include <map>
/*
Time complexity: O(Log n)
*/
int searching(const int *array, int length, int value)
{
int startIndex = 0, lastIndex = length - 1;
@canavci2016
canavci2016 / Dockerfile
Last active August 25, 2022 20:46
node-ngnix full setup on docker
ARG NODE_VERSION
FROM node:${NODE_VERSION}
ENV NODE_ENV=production
WORKDIR /usr/src/app
RUN mkdir -p /usr/src/app/api
RUN mkdir -p /usr/src/app/client
@canavci2016
canavci2016 / optimized-bubble-sort.cpp
Last active August 22, 2022 16:10
sorting algorithms
#include <iostream>
/*
it works by swaping the adjacent elements if they are in wrong order
Complexity Analysis of Selection Sort:
Time Complexity:
it always runs O(n^2) time even if the array is sorted. it was optimized by stopping algorithm
@canavci2016
canavci2016 / test.js
Last active August 10, 2022 18:52
event-loop-order-of-code
setTimeout(() => { console.log('timeout'); }, 0);
setImmediate(() => { console.log('immediate'); });
const fs = require('fs');
fs.readFile(__filename, () => {
setTimeout(() => {
console.log('timeout');
}, 0);
setImmediate(() => {
@canavci2016
canavci2016 / nodejs-directory-structure.md
Last active July 31, 2022 12:16 — forked from miguelmota/nodejs-directory-structure.md
Node.js MVC directory structure example.
Node.js MVC directory structure example.
├── app
│   ├── services
│   │   ├── admin
│   │   │   ├── posts.js
│   │   │   └── users.js
│   │   ├── posts.js
│   │   ├── session.js