Skip to content

Instantly share code, notes, and snippets.

git config --global alias.lg 'log --pretty=format:"%h%ad | %s%d [%an]" --graph --date=short'
@Galarius
Galarius / git-snippets.txt
Created October 28, 2017 08:23
git snippets
git filter-branch --index-filter \
'git rm --cached --ignore-unmatch <file>'
That will remove <file> from all commits, starting from the root commit.
@Galarius
Galarius / remove_mail_archive.txt
Last active April 5, 2023 05:28
gmail: remove archive
has:nouserlabels !in:Inbox -label:sent -label:drafts
sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/SierraBootInstall --applicationpath /Applications/Install\ macOS\ Sierra.app --nointeraction &&say Done
@Galarius
Galarius / winapi_create_detached_proc.cpp
Created October 22, 2016 08:55
Create independent process in Win API
#include <Windows.h>
#include <cstdio>
void MsgBoxLastError()
{
LPWSTR lpMsgBuf = NULL;
if (FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
@Galarius
Galarius / self-detach.sh
Created October 22, 2016 07:41
Self-detaching shell script
#!/bin/bash
# self-detach.sh
# Self-detaching shell script
#------------------------------------------
if [ -z "$_DETACHED_" ]
then
# Run this script silently in background
# mode with low priority
_DETACHED_=1 nohup nice sh $0 &>/dev/null
@Galarius
Galarius / recover_safari.sh
Created October 8, 2016 16:09
Copy Safari from recovery partition
diskutil mount Recovery\ HD
hdiutil mount /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg
cp -R /Volumes/OS\ X\ Base\ System/Applications/Safari.app /Applications
path1 = 'text_ru.txt'
path2 = 'text_ru.uppercase.txt'
f = open(path1, 'r')
w = open(path2, 'w')
lines = f.readlines()
lines = [unicode(line.decode('utf-8')) for line in lines]
lines = [line.upper() for line in lines]
lines = [line.encode('utf-8') for line in lines]
w.writelines(lines)
w.close()
@Galarius
Galarius / Setting _QT_in_Xcode.md
Created March 15, 2016 17:32
Setting QT in Xcode
@Galarius
Galarius / TheGashlyCodeTinies.txt
Created August 30, 2015 16:26
The GashlyCode Tinies
A is for Amy whose malloc was one byte short
B is for Basil who used a quadratic sort
C is for Chuck who checked floats for equality
D is for Desmond who double-freed memory
E is for Ed whose exceptions weren’t handled
F is for Franny whose stack pointers dangled
G is for Glenda whose reads and writes raced