Skip to content

Instantly share code, notes, and snippets.

@linuxbender
linuxbender / Convert-VMWare-VirtualBox-image
Created May 28, 2011 23:59
Convert Image from VMWare (vmdk) to VirtualBox (vdi)
# Convert vmdk image to vdi image
+ example kdenlive demo image
VBoxManage clonehd --format vdi kdenlive-x64-20090612.vmdk kdenlive.vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in
format 'vdi'. UUID: 16b93434-ad55-465d-ad2a-77dab75c9223
# htop iotop atop pciutils
# vmware tools and setup
@linuxbender
linuxbender / powershell-001.ps1
Created June 14, 2011 21:17
read OS name – Service Pack – last boot – up time
# read info from the current host
# replace "." with your remote host - if you like
$OS = get-wmiobject win32_operatingsystem -ComputerName .
# default values
$OSSP = "{n.a}"
$OSName = "{n.a}"
$OSLastBoot = "{n.a}"
$OSUpTime = "{n.a}"
@linuxbender
linuxbender / JsonController
Created September 6, 2011 22:54
script-holder
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace demo_03.Controllers
{
public class JsonController : Controller
{
@linuxbender
linuxbender / pseudo-classes.css
Created September 10, 2011 18:33
pseudo classes
/* link to the source: http://webdesign.about.com/od/css3/qt/alternating-row-styles-tables.htm */
/* http://www.w3schools.com/css/css_pseudo_classes.asp */
/*table http://webdesign.about.com/od/tables/ss/aa120897.htm */
/* Select the last 4 element from a list */
li:nth-last-child(-n+4) { background-color: #ccc; }
/* zebra */
li:nth-child(odd){background-color: #eee;}
li:nth-child(even){background-color: #ddd;}
/* zebra rows in table */
@linuxbender
linuxbender / RegexSearchKanton.cs
Created September 25, 2011 20:21
Regex Search Kanton Table
var pattern = @"^Sl[A-Z]{1}";
var stringSearch = "SlKanton";
var demo = Regex.Match(stringSearch, pattern);
Console.WriteLine("Wurde der Wert gefunden ? : {0} der wert is : {1}",demo.Length ,demo.Value);
if (demo.Success)
{
Console.WriteLine(stringSearch.Remove(demo.Index, demo.Length - 1));
}
Console.ReadLine();
@linuxbender
linuxbender / zebra.js
Created September 28, 2011 20:09
zebra.js
$("tr:nth-child(odd)").addClass("odd");
$("tr:nth-child(odd)").hover(function(){
$(this).addClass("odd_over");
},function(){
$(this).addClass("odd_out");
});
$("tr:nth-child(even)").hover(function(){
$(this).addClass("even_over");
@linuxbender
linuxbender / install-rvm-rubyonrails.bash
Created October 9, 2011 18:31
Install rvm rubyonrails 3.1.1 linux (ubuntu in my case)
# rvm homepage :http://beginrescueend.com/
# rubyonrails homepage :http://rubyonrails.org/
# using gemset : http://beginrescueend.com/gemsets/using/
# js env : https://github.com/sstephenson/execjs
# heroku hosting : http://www.heroku.com/
# github repo : https://github.comlow
# gmate for gedit : https://github.com/gmate/gmate
# ruby dependencies
sudo apt-get install build-essential openssl libssl-dev libreadline6 libreadline6-dev curl
@linuxbender
linuxbender / gist:1786130
Created February 10, 2012 03:29
How to Unit Test Data Annotation Validators
[TestMethod]
public void Description_Should_Be_Required()
{
Expression<Func<MenuCategoryBusinessObject, object>> expression =
o => o.Description;
var me = expression.Body as MemberExpression;
var att = (RequiredAttribute[])me.Member
.GetCustomAttributes(typeof(RequiredAttribute), false);
att.Length.ShouldEqual(1);
}
@linuxbender
linuxbender / MyHelper.cs
Created May 17, 2011 12:13
MVC 3 - Razor - C# -Custom helper: @Html.Script
using System.Web.Mvc;
namespace Starwolf.ch.Helpers
{
public static class MyHelpers
{
public static MvcHtmlString Script(this HtmlHelper helper, string src)
{
// <script src="@Url.Content("~/Scripts/jquery-1.6.1.min.js")" type="text/javascript"></script>
var builder = new TagBuilder("script");
<!--<rewrite>
<rules>
<rule name="Redirect to HTTPS" enabled="true" stopProcessing="true">
<match url="^home" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="([^/:]*?):[^/]*?" />
</conditions>
<action type="Redirect" url="https://{C:1}:44300/{REQUEST_URI}" />
</rule>