Skip to content

Instantly share code, notes, and snippets.

View wojciech-kulik's full-sized avatar
🤩
Fascinated by Neovim

Wojciech Kulik wojciech-kulik

🤩
Fascinated by Neovim
View GitHub Profile
@wojciech-kulik
wojciech-kulik / file-history.sh
Last active October 16, 2024 22:48
Git file history + diff (even if moved or renamed)
function file-history() {
if [ -z "$2" ]; then
file_pattern="$(basename "$1")"
else
file_pattern="$2"
fi
git log --oneline --abbrev-commit --follow "$1" |
fzf --ansi --preview "commit=\$(echo {1} | cut -d' ' -f1); \
file=\$(git show --pretty='' --name-only \$commit | grep -i '$file_pattern'); \
@wojciech-kulik
wojciech-kulik / index.html
Last active May 22, 2022 12:32
HTML Sample
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
@wojciech-kulik
wojciech-kulik / DuplicatedFrameworksRemover.rb
Last active September 14, 2021 19:50
Duplicated frameworks remover
#
# DuplicatedFrameworksRemover.rb
# Created by Wojciech Kulik on 14/09/2021.
#
# Description:
# This code fixes warnings caused by linking the same frameworks in multiple targets.
#
# Sample warning: "objc[1111]: Class XXXX is implemented in both path/FrameworkName1 and path/FrameworkName2.
# One of the two will be used. Which one is undefined."
@wojciech-kulik
wojciech-kulik / FixedComboBox.swift
Last active September 3, 2020 22:43
NSComboBox - fixed disappearing list
//
// FixedComboBox.swift
// Snippety
//
// Created by Wojciech Kulik on 03/09/2020.
// Copyright © 2020 Wojciech Kulik. All rights reserved.
//
import Cocoa
@wojciech-kulik
wojciech-kulik / GetSingleInstanceCounter.cs
Last active December 16, 2015 18:37
GetSingleInstanceCounter
[DllImport("pdh.dll", SetLastError = true, CharSet = CharSet.Unicode)]
static extern UInt32 PdhLookupPerfNameByIndex(string szMachineName, uint dwNameIndex, StringBuilder szNameBuffer, ref uint pcchNameBufferSize);
PerformanceCounter GetSingleInstanceCounter(string englishCategoryName, string englishCounterName)
{
// Try first with english names
try
{
return new PerformanceCounter(englishCategoryName, englishCounterName);
}
@wojciech-kulik
wojciech-kulik / IPConnectivity.cs
Last active November 26, 2015 17:42
IPConnectivity
// the order is important, if we want to support bitwise OR: IPv4 | IPv6 equals IPv4and6
public enum IpVersion
{
None,
IPv4,
IPv6,
IPv4and6
}
public async Task<IpVersion> GetCurrentIpVersion()
// the order is important, if we want to support bitwise OR: IPv4 | IPv6 equals IPv4and6
enum IpVersion
{
None,
IPv4,
IPv6,
IPv4and6
}
IpVersion GetConfiguredProtocolVersions(ConnectionProfile profile)
@wojciech-kulik
wojciech-kulik / producer_consumer.cpp
Created November 4, 2015 21:26
[C++] Producer-consumer problem - http://wojciechkulik.pl
#include <iostream>
#include <thread>
#include <array>
#include <vector>
#include <mutex>
#include <string>
#include <condition_variable>
#include <queue>
#include <algorithm>
@wojciech-kulik
wojciech-kulik / longest_subsequence.cpp
Created November 4, 2015 21:24
[C++] Longest common subsequence - http://wojciechkulik.pl
#include <iostream>
#include <string>
using namespace std;
struct Field
{
char c;
int length;
Field * previous;
@wojciech-kulik
wojciech-kulik / kruskal.cpp
Created November 4, 2015 21:22
[C++] Kruskal's algorithm - http://wojciechkulik.pl
#include <stdio.h>
struct Edge
{
int a, b;
int weight;
};
struct Vertex
{