Skip to content

Instantly share code, notes, and snippets.

View onsah's full-sized avatar
🎯
Focusing

Onur Şahin onsah

🎯
Focusing
View GitHub Profile
#! /usr/bin/env bash
# Script to install NixOS from the Hetzner Cloud NixOS bootable ISO image.
# (tested with Hetzner's `NixOS 20.03 (amd64/minimal)` ISO image).
#
# This script wipes the disk of the server!
#
# Instructions:
#
# 1. Mount the above mentioned ISO image from the Hetzner Cloud GUI
@onsah
onsah / shell.nix
Last active October 17, 2023 09:19
Nix Shell Template
# Assumes, there is a channel called 'nixpkgs', see https://nixos.wiki/wiki/Nix_channels
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = with pkgs; [
# Package goes there
# You can search packages via `nix search $term` or from https://search.nixos.org/packages
];
}
struct Node {
Node() : next{0}, value{0}, head{true}
{ }
Node(int val, Node* next = 0) : next{next}, value{val}, head{false}
{ }
~Node() {
if (next)
delete next;
}
@onsah
onsah / Test
Created December 29, 2018 17:09
#include "PhoneBook.h"
#include <cassert>
int main(int argc, char const *argv[])
{
PhoneBook pb;
assert(pb.addPerson("onur"));
assert(pb.addPerson("can"));
assert(pb.addPerson("betul"));
assert(!pb.addPerson("onur"));
int main()
{
std::chrono::time_point< std::chrono::system_clock > startTime;
std::chrono::duration< double, std::milli > elapsedTime;
for (int i = 0; i < MAX_VALUE; i += 10000000) {
startTime = std::chrono::system_clock::now();
for (int j = 0; j < REPEAT; ++j) {
//call the function
int result = fib(i);
#include "MAC.h"
#include <iostream>
MAC::MAC() : musicAlbums{nullptr},
noOfMusicAlbums{0},
_cap{0}
{
}
MAC::~MAC()
struct test_vector_insert
{
kstd::vector<int> test_vector;
test_vector_insert() : test_vector()
{
for (int i = 1; i <= 10; ++i)
{
test_vector.push_back(i);
}
require_begin_insert();
@onsah
onsah / nucleotide.c
Created October 31, 2018 20:39
Ödev
#include <stdio.h>
void print_pairs(const char *nucleotides, int len)
{
int count = 0;
for (int i = 0; i < len; ++i) {
if (nucleotides[i] == nucleotides[i + 1]) {
count += 1;
printf("%c%c\n", nucleotides[i], nucleotides[i]);
}