Skip to content

Instantly share code, notes, and snippets.

package = ktor.cinterop.winhttp
headers = wtypes.h winhttp.h
headerFilter = winhttp.h
compilerOpts = -DUNICODE
linkerOpts = -lwinhttp
---
// These WebSocket declarations are not present in our sysroots,
// so we add them here.
#define WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET 114
@sbogolepov
sbogolepov / bench.kt
Last active June 6, 2018 10:01
Switch lowering outcome
import kotlin.system.measureNanoTime
enum class MyEnum {
ITEM1, ITEM2, ITEM3, ITEM4, ITEM5, ITEM6, ITEM7, ITEM8, ITEM9, ITEM10, ITEM11, ITEM12, ITEM13, ITEM14, ITEM15, ITEM16, ITEM17, ITEM18, ITEM19, ITEM20, ITEM21, ITEM22, ITEM23, ITEM24, ITEM25, ITEM26, ITEM27, ITEM28, ITEM29, ITEM30, ITEM31, ITEM32, ITEM33, ITEM34, ITEM35, ITEM36, ITEM37, ITEM38, ITEM39, ITEM40, ITEM41, ITEM42, ITEM43, ITEM44, ITEM45, ITEM46, ITEM47, ITEM48, ITEM49, ITEM50, ITEM51, ITEM52, ITEM53, ITEM54, ITEM55, ITEM56, ITEM57, ITEM58, ITEM59, ITEM60, ITEM61, ITEM62, ITEM63, ITEM64, ITEM65, ITEM66, ITEM67, ITEM68, ITEM69, ITEM70, ITEM71, ITEM72, ITEM73, ITEM74, ITEM75, ITEM76, ITEM77, ITEM78, ITEM79, ITEM80, ITEM81, ITEM82, ITEM83, ITEM84, ITEM85, ITEM86, ITEM87, ITEM88, ITEM89, ITEM90, ITEM91, ITEM92, ITEM93, ITEM94, ITEM95, ITEM96, ITEM97, ITEM98, ITEM99, ITEM100
}
private fun enumSwitch(x: MyEnum) : Int {
when (x) {
MyEnum.ITEM5 -> return 1
MyEnum.ITEM10 -> return 2
#include <iostream>
#include <type_traits>
#include <variant>
#include <vector>
#include <typeinfo>
int main() {
std::variant<std::string, int, bool> mySetting = "Hello!";
if (std::holds_alternative<bool>(mySetting)) {
std::cout << "WAT" << std::endl;
package com.github.aceisnotmycard.contollers;
import com.github.aceisnotmycard.repositories.entities.BaseEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.web.bind.annotation.*;
import java.util.List;
class BaseController<Entity extends BaseEntity> {
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <limits.h>
int char_to_value (char ch);
int *number_to_array (char *number);
@sbogolepov
sbogolepov / main.c
Last active December 26, 2015 16:59
:3
#include "convertor.h"
int main (int argc, char **argv) {
//b2
int target_base;
//b1
int given_base;
int *value;
unsigned int value_in_ten_base;
@sbogolepov
sbogolepov / convertor.c
Last active December 26, 2015 15:19
For one pretty girl
#include "convertor.h"
//Converting sign of digit ("A") to digit itself (10);
int char_to_value (char ch) {
//Первый случай: Буква большая. Тогда возвращаем разницу
//между кодами ch и 'A' и прибавляем десятку.
//Пример (ch = 'F'): 'F' - 'A' + 10 = 70 - 65 + 10 = 15
if (isupper (ch))
return ch - 'A' + 10;
//
// Created by Sergey Bogolepov on 24/12/15.
//
#ifndef SMART_PTR_SMART_PTR_H
#define SMART_PTR_SMART_PTR_H
#include <iostream>
template<typename T>
package io.aceisnotmycard.redtooth.communication;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@sbogolepov
sbogolepov / third.sql
Created December 14, 2015 13:31
Выбрать сотрудников, имеющих оклад равный минимальному окладу подразделения, где они работают. Исключить из выборки сотрудников, которые не приписаны ни к какому подразделению.
SELECT emp.employee_id,
emp.last_name,
emp.salary,
emp.department_id
FROM hr.employees emp
WHERE emp.salary =
(SELECT min(salary)
FROM hr.employees b
WHERE emp.department_id = b.department_id)