Skip to content

Instantly share code, notes, and snippets.

@linuxbender
linuxbender / Linq - C
Created April 29, 2011 09:42
Linq and SQL - group max date - show latest entry - example
// http://creativecommons.org/licenses/by-nc-sa/3.0/
var foo = from p in _db.tblFactories
group p by p.tblFactoryName into grp
let tblFactoryExportDate = grp.Max(p => p.tblFactoryExportDate)
let tblFactoryName = grp.Key
from p in grp
where p.tblFactoryName == tblFactoryName &&
p.tblFactoryExportDate == tblFactoryExportDate
@linuxbender
linuxbender / wget
Created April 30, 2011 09:42
wget command to backup a page
wget --no-cache --mirror --convert-links --user-agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092416 Firefox/3.0.3" -x -w 1 -B -r -k -p http://www.demo.dev/
sudo mount mycd.iso /media/CD -o loop -t iso9660
@linuxbender
linuxbender / DatTime.cs
Created May 3, 2011 08:44
C# DateTime convert to Type double or long example and back to DateTime
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DateTimeLongCompare
{
class Program
{
static void Main(string[] args)
@linuxbender
linuxbender / dt.sql
Created May 3, 2011 10:04
MS SQL 2k8 Datetime convert - not working - just past to the inet
DECLARE @myDouble float(30)
SET @myDouble = 40666.4704123611
DECLARE @myLong bigint
SET @myLong = 634400182498630741
-- o.k double to DateTime
select @myDouble as NR , convert(datetime, @myDouble) as DT
@linuxbender
linuxbender / .bash_profile
Created May 11, 2011 12:28
SSH with plink (putty) = remote send linux command
if [[ $- != *i* ]] ; then
ON_A_TTY=No
else
ON_A_TTY=Yes
fi
# check that an ssh-agent is running
if [ -x /usr/bin/ssh-agent ]
then
SSH_AGENT_PID=-1
@linuxbender
linuxbender / startxfce4 -- :1
Created May 11, 2011 21:14
startxfce on second screen
startxfce4 -- :1
@linuxbender
linuxbender / join01.cs
Created May 12, 2011 12:39
Linq and C# - Join example
long tblUnitID = 808;
var _rec = (from u in _db.tblUnits
join ut in _db.tblUnitTypes on u.tblUnitTypeID equals ut.tblUnitTypeID into gj
from subset in gj.DefaultIfEmpty()
where u.tblUnitID == tblUnitID
select new { u.tblUnitID, u.tblUnitName, u.tblUnitTypeID, tblUnitTypeName = (subset == null ? String.Empty : subset.tblUnitTypeName) }).FirstOrDefault();
Console.WriteLine("{0} {1} {2} {3}",_rec.tblUnitID, _rec.tblUnitName, _rec.tblUnitTypeID, _rec.tblUnitTypeName);
@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");
@linuxbender
linuxbender / SummaryForm.cshtml
Created May 17, 2011 12:43
MVC 3 - Razor - C# - RenderPage - Code snippe
<!-- all manip with JQuery - her without jquery -->
<ul class="popupMenu">
<li>
<label>
<strong>Priority :</strong>
</label>
</li>
<li>
<select class="popupSelectP">
<option value="0">Select Priority</option>