Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
function do_if(){
echo $1 "(y/n)"
read install
if [ $install == "y" ]
then
echo $2
eval $2
fi
}
@vinntreus
vinntreus / Nice git commands
Last active October 14, 2023 08:39
Git kommandon som är bra att känna till
Git kommandon som är bra att känna till
Hämta ut commit där man satte TAG
git rev-list $TAG | head -n 1
Alias till trevlig log (git lg)
git config --global alias.lg "log --pretty=format:'%Cgreen%h%Creset : %C(bold)%s %Creset(%an, %ar)'"
För mac med mörkt tema:
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@vinntreus
vinntreus / from_cp850_to_windows1252.rb
Created June 5, 2012 19:26
åäö in ruby (that works in windows console)
require 'iconv'
def convert_to_windows1252 (input)
ic = Iconv.new('Windows-1252', 'CP850')
return ic.iconv(input + ' ')[0..-2]
end
@vinntreus
vinntreus / LdapObject
Created April 11, 2012 21:52 — forked from daniellee/LdapObject
LdapObject without interface
public static class LdapParser
{
private static readonly Regex Parser = new Regex("^cn=(?<object>.*?),(?<context>.*)$", RegexOptions.IgnoreCase);
public static T Parse<T>(string s) where T : LdapObject, new()
{
if (string.IsNullOrWhiteSpace(s)) return default(T);
var m = Parser.Match(s);
return
@vinntreus
vinntreus / gist:1099173
Created July 22, 2011 09:40
Setup mvc controller to be able to call Url.Action
public static void SetupWithHttpContextAndUrlHelper(this Controller controller)
{
var routes = new RouteCollection();
MvcApplication.RegisterRoutes(routes);
//setup request
var requestContextMock = new Mock<HttpRequestBase>();
requestContextMock.Setup(r => r.AppRelativeCurrentExecutionFilePath).Returns("/");
requestContextMock.Setup(r => r.ApplicationPath).Returns("/");