Skip to content

Instantly share code, notes, and snippets.

View vansickle's full-sized avatar

Pavel Samokha vansickle

  • Vantaa, Finland
View GitHub Profile
@vansickle
vansickle / Program.fs
Last active April 3, 2019 10:37
Sort array ["world", "10", "4", "hello", "1"] to ["hello", "1", "4", "world", "10"] using F#
open System
//input = ["world", "10", "4", "hello", "1"]
//
//output = sort_strings(input)
//
//assert output == ["hello", "1", "4", "world", "10"]
[<EntryPoint>]
let main argv =
Diagram(
NonTerminal('PREFIX'),
Choice(0,
Sequence(
Terminal('segmentation'),
NonTerminal('segmentation-class'),
),
Sequence(
Terminal('change'),
Choice(0, NonTerminal('change-class'), Skip()),
@vansickle
vansickle / make-squashed-repo.sh
Created October 13, 2018 18:20
How to make a squashed repo
git clone http://github.com/account/repo.git repo-public
cd repo-public
git log -1
git rev-list --max-parents=0 HEAD #find HEAD hash
git reset --soft 8b03e62214e143b9409e76376ce9afb240d6418e
git status
git commit --amend -m "Squashed public version 2018-06-09"
git remote add public
git remote add public https://github.com/public_account/repo-public.git
git push public master --force-with-lease
@vansickle
vansickle / clear-history.bash
Created October 12, 2018 15:56
Clear Bash History
cat /dev/null > ~/.bash_history && history -c && exit
@vansickle
vansickle / userChrome.css
Created October 6, 2018 12:47
Firefox 57+ Mac OS X userChrome to hide tabs bar (because of using TreeStyleTab)
#TabsToolbar { visibility: collapse !important; }
/* to hide the sidebar header */
#sidebar-header {
visibility: collapse;
}
/* move nav panel in slightly to prevent covering macOS window
controls */
#nav-bar-customization-target {
@vansickle
vansickle / git-author-rewrite-and-push.sh
Last active June 27, 2016 09:28
If you accidentally commit and push with wrong name/email - this script will help you rewrite history
#!/bin/bash
#script based on https://help.github.com/articles/changing-author-info/ article
usage="$(basename "$0") [-h] [-o OLD_EMAIL] [-n CORRECT_NAME] [-e CORRECT_EMAIL]
where:
-h show this help text"
OLD_EMAIL="vs@vs"
import urllib2
for x in range(0,4):
for y in range(0,4):
response = urllib2.urlopen('http://marathon-photo.ru/members/image.php?id=1087583&x1='+str(x*100)+'&x0=0&y1='+str(y*66.5)+'&y0=0&z=4&width=400&height=266')
with open('image'+str(x)+str(y)+'.jpg', 'wb') as output:
output.write(response.read())
using System;
using Common.Logging;
namespace PLC
{
/// <summary>
/// Simple wrapper/adapter over ILog for fine-grained testing
/// </summary>
/// <remarks>
/// If you have a lot of objects of some type and want to narrow logging
@vansickle
vansickle / delete_all_msmq_queues.ps1
Created November 12, 2011 22:05
Delete all MSMQ queues
[void] [Reflection.Assembly]::LoadWithPartialName("System.Messaging")
[System.Messaging.MessageQueue]::GetPrivateQueuesByMachine("LOCALHOST") | % {".\" + $_.QueueName} | % {[System.Messaging.MessageQueue]::Delete($_); }
echo "All MSMQ queues deleted"
@vansickle
vansickle / newdao1.cs
Created June 14, 2011 08:25
struct refactoring
public class BookDAO : DAOBase<IBook, Book>{
<...>
}