Skip to content

Instantly share code, notes, and snippets.

View andrzejkaszkowiak's full-sized avatar

Andrzej Kaszkowiak andrzejkaszkowiak

  • Poland
View GitHub Profile
@andrzejkaszkowiak
andrzejkaszkowiak / SimpleMapper.cs
Last active April 11, 2018 13:26
Simple mapper written in C#
using System.Linq;
using System.Reflection;
namespace SimpleMapper
{
public static class SimpleMapper
{
private static TTarget MapTo<TSource, TTarget>(this TSource aSource, TTarget aTarget)
{
const BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
@andrzejkaszkowiak
andrzejkaszkowiak / parse-version.js
Last active September 29, 2017 10:08
Parsing version string in JavaScript
function parseVersion(str)
{
if (typeof(str) != 'string') { return false; }
var arr = str.split('.');
// parse int or default to 0
var maj = parseInt(arr[0]) || 0;
var min = parseInt(arr[1]) || 0;
var rest = parseInt(arr[2]) || 0;
@andrzejkaszkowiak
andrzejkaszkowiak / install-font-fira-code.sh
Last active April 17, 2020 04:29
Install Fira Code font family on macOS using Homebrew Cask • https://github.com/tonsky/FiraCode
# Install Fira Code font family on macOS using Homebrew Cask • https://github.com/tonsky/FiraCode/wiki/Installing
brew tap homebrew/cask-fonts
brew cask install font-fira-code
@andrzejkaszkowiak
andrzejkaszkowiak / git-replace-branch
Created July 19, 2017 08:26
Git: replace branch with the contents of another
# remote replacement - replaces master with the contents of otherbranch
git push -f origin other-branch:master
# local replacement
git checkout beta
git branch -f alfa
#!/bin/sh
set -e
for cask in $(brew cask outdated | awk '{ print $1 }'); do
brew cask uninstall --force "${cask}"
brew cask install "${cask}"
done
@andrzejkaszkowiak
andrzejkaszkowiak / git-config-difftool-opendiff.sh
Created June 19, 2017 07:14
Configure git to use opendiff as a diff- and mergetool on macOS.
git config --global diff.tool opendiff
git config --global difftool.opendiff.cmd 'opendiff "$LOCAL" "$REMOTE"'
@andrzejkaszkowiak
andrzejkaszkowiak / qt-generate-xcodeproj.sh
Created June 8, 2017 21:35
Generates Xcode projects and Makefiles for Qt project. - Works recursively and scans all subfolders listed in Qt project files (option -r).
#!/bin/bash
scriptdir=`dirname "$BASH_SOURCE"`
cd $scriptdir/.. # NOTE: Change location if necessary!
qmake -spec macx-xcode -r && qmake -r
@andrzejkaszkowiak
andrzejkaszkowiak / GIF-Screencast-OSX.md
Created May 10, 2017 10:05 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@andrzejkaszkowiak
andrzejkaszkowiak / git.migrate
Created March 28, 2017 12:57 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@andrzejkaszkowiak
andrzejkaszkowiak / word2pdf.cs
Created January 4, 2017 21:11
Microsoft Word to PDF conversion
namespace WordToPDF
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Word;
using System.IO;
// Saves a Micrsoft Word document to PDF.