Skip to content

Instantly share code, notes, and snippets.

@redmanmale
redmanmale / getMissingTranslations.py
Last active April 14, 2017 14:46
Python script to generate report for missing translations for uTox develop branch
import re
import urllib.request
import os
def readFileFromUrl(url):
try:
request = urllib.request.urlopen(url)
result = request.read().decode('utf-8')
return result
except:
@redmanmale
redmanmale / git-commands
Created February 27, 2017 16:26
personal git tips&tricks
Remove all deleted files from git stage:
git rm $(git ls-files --deleted)
Update all subrepos in folder
find . -maxdepth 1 -type d -exec sh -c '(cd {} && git pull)' ';'
find . -maxdepth 1 -type d -exec sh -c '(cd {} && git checkout develop && git pull)' ';'
Clean remote and local git:
1. git remote prune --dry-run origin //-dry-run shows remore branched to be deleted without deleting
2. Delete all local branches that was merged by pattern
@redmanmale
redmanmale / unblock_files.cmd
Created October 14, 2016 13:44
Скрипт для разблокировки файлов, скачанных из сети. Разблокирует все файлы в текущей директории и подкаталогах.
REM Скрипт для разблокировки файлов, скачанных из сети. Разблокирует все файлы в текущей директории и подкаталогах.
FOR /R %%F IN (*.*) DO echo.>"%%F":Zone.Identifier
@redmanmale
redmanmale / ConsoleShutdown.cs
Created September 27, 2016 11:59
Interceptor of console shutdown event. Could give you 5 sec to cleanup your mess (make some logging) before OS kills app.
public class ConsoleShutdown
{
[DllImport("kernel32.dll")]
private static extern bool SetConsoleCtrlHandler(ControlEventHandler e, bool add);
public enum ConsoleEvent
{
CTRL_C = 0, // From wincom.h
CTRL_BREAK = 1,
CTRL_CLOSE = 2,
@redmanmale
redmanmale / PtrExtensions.cs
Created September 20, 2016 15:04
Extension method for copy array of structs from pointer (unmanaged memory) to generic collection
internal static class PtrExtensions
{
public static IEnumerable<T> GetArrayOfStruct<T>(this IntPtr ptrToStructArr, int arrSize)
{
var output = new List<T>(arrSize);
var sizeInBytes = Marshal.SizeOf(typeof(T));
for (var i = 0; i < arrSize; i++)
{
#if x64
var ptrToStruct = new IntPtr(ptrToStructArr.ToInt64() + i*sizeInBytes);
@redmanmale
redmanmale / App.config
Last active January 24, 2017 14:15
Basic log4net usage
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net configSource="Log.config" />
<appSettings>
<add key="log4net.Internal.Debug" value="true" />