Skip to content

Instantly share code, notes, and snippets.

View beratdogan's full-sized avatar

Berat Doğan beratdogan

View GitHub Profile
@beratdogan
beratdogan / gist:924b428fda750902a258448d1fd907c9
Created August 19, 2020 07:37
List all pods with their cluster local IPs.
kubectl get pods -o=jsonpath='{range .items[*]}{@.metadata.name}{"\t"}{@.status.podIP}{"\n"}{end}'
import contextvars
from pprint import pprint as pp
__pipeline = contextvars.ContextVar("pipeline")
class StartingStepAlreadySet(Exception):
pass
class StartingStepNotSet(Exception):
@beratdogan
beratdogan / Dockerfile
Created November 13, 2019 20:46
Playing with Bjoern + Falcon
FROM python:3.7-alpine
RUN apk add --no-cache make build-base libev-dev
RUN pip install bjoern
RUN pip install falcon
WORKDIR /code
COPY app.py .
@beratdogan
beratdogan / index.js
Created February 15, 2019 20:34
React Hooks with Context API Example
import React, {createContext, useEffect, useContext, useReducer} from 'react';
const initialArgs = {
count: 0
};
const CounterContext = createContext(initialArgs);
function counterReducer(state, action) {
switch (action) {
@beratdogan
beratdogan / trash_indexes.sql
Created February 4, 2019 22:10
PostgreSQL DBA Queries
SELECT s.schemaname AS sch,
s.relname AS rel,
s.indexrelname AS idx,
s.idx_scan AS scans,
pg_size_pretty(pg_relation_size(s.relid)) AS ts,
pg_size_pretty(pg_relation_size(s.indexrelid)) AS "is"
FROM pg_stat_user_indexes s
INNER JOIN pg_index i ON i.indexrelid = s.indexrelid
LEFT JOIN pg_constraint c ON i.indrelid = c.conrelid AND array_to_string(i.indkey, ' ') = array_to_string(c.conkey, ' ')
WHERE i.indisunique IS FALSE
@beratdogan
beratdogan / interview.md
Last active July 6, 2018 09:52
Awesome Interview Questions

Computation

You can just work with language-independent solutions.

  • Define a factorial function
  • Define a fibonacci function
  • Define a bubble_sort quick sort function which implements Bubble Sort algorithm.

Python Specific

  • Write a program that prints sum of even numbers from 0 to 100 as short as possible?
  • You have an list that contains lots of duplicated items. Create an unique_list function that returns a list of unique values. There are some ways to do this. The choice is yours.
  • How do you log process steps in your programs?
import os
from functools import partial
from django.contrib.sites.models import Site
from django.template.loaders.filesystem import Loader as FilesystemLoader
class SiteDirsLoader(FilesystemLoader):
def get_dirs(self):
templates_dir = super(SiteDirsLoader, self).get_dirs()[0]
Module VBModule
Sub Main()
Dim x As Integer = 0
Dim y As Integer = 0
Dim input As ConsoleKeyInfo
Do
input = Console.ReadKey(True)
int pins[] = {7, 8, 9, 10, 11, 12, 13};
int pinsLength = sizeof(pins) / sizeof(int);
void setup() {
for (int pin = 0; pin < pinsLength; pin++) {
pinMode(pins[pin], OUTPUT);
}
}
void loop() {
<?php
function partial() {
$args = func_get_args();
return function() use($args) {
return call_user_func_array('call_user_func', array_merge($args, func_get_args()));
};
}
function with()