Skip to content

Instantly share code, notes, and snippets.

@linuxbender
linuxbender / ByteInfoAttribute.cs
Created January 12, 2012 23:39
EF 4.2 - MVC 3 - File Validation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
namespace demo_002.Models
{
public class ByteInfoAttribute : ValidationAttribute
{
@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 / HerokuTemplate.t4
Created October 8, 2011 21:43
Read DataAnnotations values from the enity
<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #>
<#@ Output extension="txt" #>
<#@ assembly name="System.ComponentModel.DataAnnotations" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Data.Entity" #>
<#@ assembly name="System.Data.Linq" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Collections" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.ComponentModel.DataAnnotations" #>
@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 / 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 / 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 / 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 / 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 / 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 / note.markdown
Created May 26, 2011 19:07
note to ruby, rails,rvm,gem, bundle

RVM

fix rubygems

rvm rubygems current

switch to ruby 1.9.2

rvm ruby-1.9.2 --default

gem

list commands

gem help command