Skip to content

Instantly share code, notes, and snippets.

View AhmetCanSolak's full-sized avatar

Ahmet Can Solak AhmetCanSolak

  • Chan Zuckerberg Biohub
  • San Francisco, CA
View GitHub Profile
{
"Windows" : {
"0.0.1": "121aIVQEUjwVEZWX3OiTu17AesRDgC494",
"0.0.2": "1CECPG7WD9P9A1_ZSZFpc58SvfLx55UdR",
"0.0.3": "1Z4VYH9qSP-9mw1yX9u-W7tgAETBfathv",
"0.0.4": "14m0ShfQMPaCOuZOQ-PsLYQLXIcsUA5Fd",
"0.0.5": "1fWzHWfGp_5fprsrgI6my8I-Vjo1GKg-Z"
},
"Darwin": {
"0.0.1": "1l7fWJG5TO5tWCOAsKdM1k1kHdv0VSVem",
@AhmetCanSolak
AhmetCanSolak / layout_problem.py
Last active November 16, 2018 23:51
This is gist to reproduce the problem i'm facing with PyQt5 and VisPy
"""This gist created to demonstrate an layout error, however, problem is solved with switching to anaconda/python
"""
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QSlider, QScrollArea, QFrame, QPushButton
from PyQt5.QtWidgets import QVBoxLayout, QHBoxLayout
from vispy.scene import SceneCanvas, PanZoomCamera
class Left(QHBoxLayout):
from collections import Counter
# ------ Pythonic solution
def alternative_solution(inp):
cntr = Counter([inp[i:i+2] for i in range(len(inp)-1)])
maxc = cntr.most_common(1)[0][1]
return [key for key,elem in cntr.items() if(elem==maxc)]
# ------- Given Solution
@AhmetCanSolak
AhmetCanSolak / private_methods.py
Last active October 30, 2018 23:03
A trial to implement non-accessible private methods in python
from pprint import pprint
# CamelCase because it "acts" like a class
def CounterController():
class CounterControllerPrivate(object):
def __init__(self):
self.counter = 0
def add_one(self):
@AhmetCanSolak
AhmetCanSolak / observer.py
Created October 25, 2018 16:22
Simple demonstration of observer pattern
"""
This is a simple demonstration of observer pattern
"""
__author__ = 'AhmetCanSolak'
class Subject(object):
observers = []
def __init__(self):
self.observers = []
[
{
'CreateEvent': 183775,
'IssueCommentEvent': 99271,
'WatchEvent': 107234,
'PullRequestReviewCommentEvent': 27644,
'PushEvent': 761788,
'PullRequestEvent': 84235,
'CommitCommentEvent': 2770,
'MemberEvent': 5369,
@AhmetCanSolak
AhmetCanSolak / kundu-and-tree.cpp
Last active May 26, 2018 08:45
My solution to Kundu and Tree problem on HackerRank/Data Structures/DisjointSet
// for problem text https://www.hackerrank.com/challenges/kundu-and-tree/problem
#include <bits/stdc++.h>
typedef long long int LT; // suitable long type
using namespace std;
template<typename T>
class disjointset
{
public:
@AhmetCanSolak
AhmetCanSolak / disjointset.cpp
Last active May 22, 2018 12:06
Disjoint Set implementation
template<typename T>
class disjointset
{
public:
disjointset(int n) {
size = n;
arr.reserve(n);
rank.reserve(n);
makeSet();
setcount = n;
# Function to flatten dictionary
def flattenDict(dictionary):
results={}
for key,value in dictionary.items():
if isinstance(value,dict):
tempDict = flattenDict(value)
for subkey,subvalue in tempDict.items():
results[key+"."+subkey]=subvalue
else:
results[key]=value
@AhmetCanSolak
AhmetCanSolak / fillMatrixDiagonally.cc
Last active June 8, 2017 08:10
Fill a 2D array diagonally. In other words, reshape 1D array to 2D array diagonally.
// An C++ example to fill a 2D array diagonally, written by AhmetCanSolak
#include <bits/stdc++.h>
int main(void){
// Fill this array with the 1D array you want to reshape, current values are just for testing!
std::vector<int> my_one_dimensional_array={1,2,3,4,5,6,7,8,9,10};
//Calculate the required size for 2D result
int z =1;
while( ( ((z) * ((z)+1))/2 ) < my_one_dimensional_array.size()){