Skip to content

Instantly share code, notes, and snippets.

@foka
foka / gitlab-history-button-on-github.js
Last active January 14, 2022 12:31
Add GitLab's-like [History] button on GitHub pages via Tampermonkey
// ==UserScript==
// @name Add GitLab's-like [History] button on GitHub pages
// @namespace http://tampermonkey.net/
// @version 1.1
// @author foka
// @match *://github.com/*
// @icon https://www.google.com/s2/favicons?domain=github.com
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
@foka
foka / mywatch.sh
Last active July 18, 2019 18:41
Simple `watch` replacement. Just an exercise to make a replacement for a command missing in git-bash
#!/bin/bash
interval=$1
command=$2
while true; do
bash -c "$2"
sleep $interval
done
@foka
foka / copyAndAddNumber.sh
Last active July 14, 2019 15:55
Copy file with number suffix n-times with the number increased
#!/bin/bash
sourceFile=$1
targetDir=$2
copyCount=$3
sourceFileName=$(basename "$1")
sourceNumber=$(echo $sourceFileName | grep -oE '[0-9]+$');
prefixLength=$((${#sourceFileName}-${#sourceNumber}))
prefix=${sourceFileName:0:$prefixLength}
@foka
foka / copyByPrefix.sh
Created July 14, 2019 14:36
Copy files by prefix
ls sourceDir | grep -oP '^coolPrefix_\K.+' | awk '{print "cp sourceDir/coolPrefix_"$0 " targetDir/"$0}' | bash
@foka
foka / RetardedProfiler.cs
Last active July 15, 2019 12:19
Simple profiler. I would have used MiniProfiler but I'm in the past (using .NET 4.5)
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace Infrastructure
{
public class RetardedProfiler
@foka
foka / MyListener.cs
Last active February 14, 2019 21:30
PoC for NHIbernate problem with empty component: "When reloading the containing object, NHibernate will assume that if all component columns are null, then the entire component is null". See: https://stackoverflow.com/a/2891739/633721. EntityFeatures is my entity that has Values property of IDictionary type, mapped as dynamic component.
public class MyListener : IPostLoadEventListener
{
public void OnPostLoad(PostLoadEvent @event)
{
var entityFeatures = @event.Entity as EntityFeatures;
if (entityFeatures == null)
return;
if (entityFeatures.Values != null && entityFeatures.Values.Count != 0)
return;
@foka
foka / NoCL.sh
Created April 6, 2018 11:28
Commits (no merges) without "CL:" in body
git rev-list --no-merges RC_2.31 f3fe260995.. |
while read sha1; do
git show -s --format='%C(yellow)%h%Creset %C(green)%an%Creset %b' $sha1 | tr '\n' ' '; echo
done |
grep -v -i "CL:"
@foka
foka / ShowCL.sh
Last active March 31, 2018 13:18
Shows CL: (not: brak) commits on given branch since given commit
git rev-list --cherry-pick -i --grep="CL:\s*" RC_2.31 f3fe260995.. |
while read sha1; do
git show -s --format='%C(yellow)%h%Creset %C(green)%an%Creset %b' $sha1 | tr '\n' ' '; echo
done |
grep -v -i "CL:[[:space:]]*brak"
@foka
foka / gist:2548952351e023e3930a2e19428bd6e1
Created September 22, 2016 14:11 — forked from klovadis/gist:5170446
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
-- gets all fields from a hash as a dictionary
local hgetall = function (key)
local bulk = redis.call('HGETALL', key)
local result = {}
local nextkey
for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
else
result[nextkey] = v
@foka
foka / gist:7082135
Created October 21, 2013 11:08
Open a file concurrently - test FileShare parameter
using System.IO;
using System.Threading;
namespace TestFileShare
{
class Program
{
static void Main()
{
ThreadStart ts1 = () =>