Skip to content

Instantly share code, notes, and snippets.

View MarioBinder's full-sized avatar
:octocat:
.

Mario Binder MarioBinder

:octocat:
.
View GitHub Profile
@MarioBinder
MarioBinder / SessionExpireFilterAttribute
Created November 4, 2014 06:19
SessionExpireFilterAttribute
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class SessionExpireFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var ctx = HttpContext.Current;
if (ctx.Session["RegisteredUser"] == null || !filterContext.HttpContext.Request.IsAuthenticated)
{
FormsAuthentication.SignOut();
ctx.Session.Clear();
@MarioBinder
MarioBinder / bug tracking applications
Created November 4, 2014 08:10
bug tracking applications
## bug tracking applications for developers
+ [BugLog](http://www.bugloghq.com/) (opensource)
+ [BugNET Issue Tracker](http://www.bugnetproject.com/) (commercial, opensource)
+ [Trac](http://trac.edgewall.org/)
+ [Bugzilla](http://www.bugzilla.org/) (opensource)
+ [Snowy Evening](https://snowy-evening.com/)
+ [MantisBT](http://www.mantisbt.org/) (commercial, free plan)
+ [Bugify](https://bugify.com/) (commercial)
+ [Lighthouse](http://lighthouseapp.com/) (commercial)
+ [TheBuggenie](http://www.thebuggenie.com/) (commercial)
public static class Crud
{
public static int Save<T>(this T entity, ZeiterfassungsContext ctx) where T : class, ICrud
{
if (entity == null)
throw new ArgumentNullException("entity", "Die Entität darf nicht null sein");
return Exists(entity, "Id", ctx) ? Update(entity, ctx) : Insert(entity, ctx);
}
public static int Insert<T>(this T entity, ZeiterfassungsContext ctx) where T : class, ICrud
@MarioBinder
MarioBinder / Extendend Version
Created September 18, 2012 04:05
Bindable Run
public static class BindableExtender {
public static string GetBindableText(DependencyObject obj) {
return (string)obj.GetValue(BindableTextProperty);
}
public static void SetBindableText(DependencyObject obj,
string value) {
obj.SetValue(BindableTextProperty, value);
}
@MarioBinder
MarioBinder / Example
Created September 26, 2012 16:35
SQL Procedure -EF Code First
db.Database.SqlCommand("dbo.News_Insert @Title, @Body, @NewsStatusId",
new SqlParameter("Title", news.Title),
new SqlParameter("Body", news.Body),
new SqlParameter("NewsStatusId", news.NewStatus.Id));
@MarioBinder
MarioBinder / font combinations
Created November 4, 2014 08:19
font combinations
## Font Combinations
+ [Beatiful Web Type Combinations](http://bueltge.de/free-web-font-combinations/)
+ [Typ.io](http://www.typ.io/)
+ [Google Web Fonts Typographic Project](http://femmebot.github.io/google-type/)
+ [Discover.typograhy](http://discover.typography.com/)
+ [I Font You](http://ifontyou.com/)
+ [Type Connection](http://www.typeconnection.com/)
+ [Beatiful Web Type](http://hellohappy.org/beautiful-web-type/)
+ [Typewolf](http://www.typewolf.com/)
+ [Just my type](http://justmytype.co/)
@MarioBinder
MarioBinder / WaitAndRetry.cs
Last active August 15, 2017 05:47
wait and retry method pattern
public static class WaitAndRetry
{
public static void Do(Action action, TimeSpan waitInterval, int retryCount = 3)
{
Do<object>(() => { action(); return null; },
waitInterval, retryCount);
}
public static T Do<T>(Func<T> action, TimeSpan waitInterval, int retryCount = 3)
{
@MarioBinder
MarioBinder / serializeObject
Created August 22, 2017 07:23
serializeObject
//https://stackoverflow.com/a/17488875/119109
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
@MarioBinder
MarioBinder / Controller.cs
Last active August 22, 2017 09:27
ForceDownload Ajax, ASP.NET MVC
public ActionResult Export(ViewModel model)
{
var fileData = _repo.GetFile(model...);
var serializer = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue, RecursionLimit = 100 };
var dataJson = new DownloadAjaxResult(true)
{
File = fileData,
Filename = model.Filename
};
return new ContentResult()
@MarioBinder
MarioBinder / sqlupdate_innerjoin.sql
Created December 14, 2017 06:42
SQL Update with Inner Join
UPDATE s
SET s.IsFreezed = 1
FROM [DBNAME].[dbo].[COLUMN] AS s
INNER JOIN [DBNAME].[dbo].[COLUMN] AS m
ON s.Id = m.StatusId
WHERE m.Subject = 'xxxxx'
AND s.HasSent = 0;