Skip to content

Instantly share code, notes, and snippets.

View TowardsDeath's full-sized avatar
⚰️
Dead

Robert van Kempen TowardsDeath

⚰️
Dead
View GitHub Profile

Keybase proof

I hereby claim:

  • I am donormal on github.
  • I am donormal (https://keybase.io/donormal) on keybase.
  • I have a public key ASB4gwRND0EgPRZ1zSAK_KvFVtUkmLEx8BNe8ndK3MkSbQo

To claim this, I am signing this object:

@TowardsDeath
TowardsDeath / progress.js
Created August 15, 2012 18:42
jQuery progress handler
$.ajax({
type: 'POST',
url: '/files/upload',
/* jQuery automatically processes and transforms Ajax data into a querystring.
* It should not do that with our binary data. */
processData: false,
data: file,
/* The 'upload' object and onprogress event are part of the new XmlHttpRequest (XHR) 2.
* With jQuery v1.7.2 there's no direct way to access this event,
* so we need to manually access the core XmlHttpRequest object to attach an event handler.
@TowardsDeath
TowardsDeath / gist:1250247
Created September 29, 2011 08:04
RSS with MVC
using System;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Web.Mvc;
using System.Xml;
namespace Web
{
public class RssController : Controller
{
@TowardsDeath
TowardsDeath / gist:849035
Created March 1, 2011 12:02
Queries generated by LLBLGen from gist 849013
SELECT
DISTINCT TOP 1 COUNT(*) AS [LPAV_]
FROM
(
SELECT
[LPLA_1].[Id]
FROM
[Tag] [LPLA_1]
WHERE
[LPLA_1].[Title] = 'title1'
@TowardsDeath
TowardsDeath / gist:849013
Created March 1, 2011 11:39
Find articles with all given tags (Linq/LLBLGen)
var tags = from t in data.Tag
where t.Title == tagTitle || t.Title == subTagTitle
select t.Id;
var list = ( from articlesWithTags in
(
from articleTag in data.ArticleTag
where tags.Contains( articleTag.TagId )
select articleTag
)
@TowardsDeath
TowardsDeath / gist:831558
Created February 17, 2011 11:43
Tag-and-role query with Linq / LLBLGen
var tags = from tag in data.Tag
join articleTag in data.ArticleTag on tag.Id equals articleTag.TagId
join articlesWithRole in
(
from articleTag in data.ArticleTag
join tagRole in data.TagForRole on articleTag.TagId equals tagRole.TagId
select new
{
ArticleId = articleTag.ArticleId,
Role = tagRole.Role