Skip to content

Instantly share code, notes, and snippets.

View tamert's full-sized avatar
:octocat:
Edit status

Tamer Ağaoğlu tamert

:octocat:
Edit status
View GitHub Profile
@tamert
tamert / record_1.ts
Created September 12, 2021 09:51
record.ts
const skills: Record<string, number> =  {
leadership: 5,
analytical: 4,
teamWorking: 3
}
console.log(skills);
@tamert
tamert / user.ts
Last active September 6, 2021 07:17
User
class User {
constructor(private firstName: string, private lastName: string) {
this.firstName = firstName;
this.lastName = lastName;
}
getFullName(): string {
return `${this.firstName} ${this.lastName}`;
}
@tamert
tamert / MultipleInheritance.ts
Created September 5, 2021 14:19
Typescript Multiple Inheritance
function applyMixins(derivedCtor: any, baseCtors: any[]) {
baseCtors.forEach(baseCtor => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
derivedCtor.prototype[name] = baseCtor.prototype[name];
});
});
}
class Animal {
name: string;
@tamert
tamert / MonologTest.php
Created May 13, 2021 22:24
Symfony + Sentry + Monolog - Logging
<?php
namespace App\Command;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Command\Command;
class MonologTest extends Command

This demonstrates the implementation of full text search for documents in Indexed DB.

  • Word-breaking and stemming is used to create a list of terms for each document.
  • Document records are annotated with the list of terms when added to the database.
  • A multi-entry index on the list of terms is populated.
  • A query is similarly processed into a list of terms.
  • A join over the terms is implemented using multiple cursors on the index.

The necessity of annotating records with the word list to populate the index is a limitation of the current Indexed DB API. A feature request to support custom

@tamert
tamert / urls.py
Created September 15, 2020 18:57
urls.py
from django.urls import include, path
from rest_framework import routers
from views import CompaniesView
router = routers.DefaultRouter()
urlpatterns = [
path('companies', CompaniesView.as_view()),
path('', include(router.urls)),
]
@tamert
tamert / views.py
Created September 15, 2020 18:53
views.py
from .models import Company
from .serializers import CompanySerializer
from rest_framework.generics import ListAPIView
class CompaniesView(ListAPIView):
queryset = Company.objects.all()
serializer_class = CompanySerializer
search_fields = ['name']
ordering_fields = ['id', 'name', 'created_at']
@tamert
tamert / serializers.py
Created September 15, 2020 18:40
serializers.py
from .models import Company
from rest_framework import serializers
class CompanySerializer(serializers.ModelSerializer):
name = serializers.CharField(required=True, max_length=190)
email = serializers.EmailField(required=True, max_length=190)
logo = serializers.CharField(required=True, max_length=190)
www = serializers.URLField(required=True, max_length=190)
linkedin = serializers.CharField(required=False, max_length=190)
@tamert
tamert / model.py
Last active September 15, 2020 18:47
model.py
from django.db import models
class Company(models.Model):
name = models.CharField(max_length=200, unique=True)
email = models.EmailField(unique=True)
www = models.URLField()
linkedin = models.URLField(null=True,)
pub_date = models.DateTimeField(null=True)
created_at = models.DateTimeField(auto_now_add=True)
@tamert
tamert / 6_reduce.py
Created September 9, 2020 21:14
6_reduce.py
from functools import reduce
liste = [1,2,3,4,5]
def carp(mevcut, siradaki):
return mevcut*siradaki
print(reduce(carp, liste))
#out: 120