Skip to content

Instantly share code, notes, and snippets.

View jincod's full-sized avatar

Vadim Abdrashitov jincod

View GitHub Profile
@jincod
jincod / HomeController.cs
Created April 26, 2012 15:50
Posting json object which will bind IDictionary<>
public class Notification
{
public string Name { get; set; }
public IDictionary<string, string> Fields { get; set; }
}
[HttpPost]
public ActionResult Send(string id, Notification viewModel)
{
string name = viewModel.Name;
@jincod
jincod / app.js
Created July 2, 2012 11:54
Backbone.js ctrl+left/right hot keys
var eventObject = {};
_.extend(eventObject, Backbone.Events);
//http://jsfiddle.net/vBh47/8/
(function (codes, eventObject, code, evt) {
document.addEventListener && // Modern browsers only
document.addEventListener("keydown", function (e) {
code = codes[e.keyCode];
if (e.ctrlKey || e.metaKey && code) {
@jincod
jincod / gist:3840929
Created October 5, 2012 16:47
FluentSecurity 1.4 and ASP.NET MVC 4

Last night I've update asp.net mvc to 4 version in my project. I'm using FluentSecurity version 1.4. After references were updated, and I ran security tests and got the exception:

System.Security.VerificationException : Method FluentSecurity.ConfigurationExpression.For: type argument 'MvcApplication1.Controllers.HomeController' violates the constraint of type parameter 'TController'.

Should add to test library app.config for fix this problem. App.config:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
@jincod
jincod / gist:3960319
Created October 26, 2012 17:59
Run NUnit tests from psake
task Tests {
$tests = (Get-ChildItem $BinDir -Recurse -Include *Tests.dll)
& $nunit /noshadow /xml:"$BinDir\Tests.nunit.xml" $tests
}
@jincod
jincod / gruntfile.coffee
Last active December 16, 2015 22:39
Complie coffee to js, run jasmine tests after coffee files changed
module.exports = (grunt) ->
grunt.initConfig
coffee:
compile:
files:
'src/src.js': ['src/*.coffee']
'specs/specs.js': ['specs/*.coffee']
jasmine:
src: ['src/**/*.js']
@jincod
jincod / index.html
Created August 21, 2013 17:20
Hogan.js bug during render list with helper
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hogan.js bug</title>
</head>
<body>
Expected:
<div>
Value1 <span><b>first,Value1 </b><b>second,Value1 </b><b>third,Value1 </b></span>
@jincod
jincod / new.ps1
Created April 22, 2014 19:05
Refactoring build script on Psake
task Clean {
exec -maxRetries 3 {
Get-ChildItem . -Include bin,obj,*.orig -Recurse | Remove-Item -Recurse -Force
}
}
@jincod
jincod / build.cmd
Created April 23, 2014 16:34
Run Psake tasks on TeamCity
@echo off
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "& {& Scripts\nuget.exe install Psake -Version 4.3.2 -o packages; .\packages\psake.4.3.2\tools\psake.cmd .\Scripts\default.ps1 %*; exit $lastexitcode;}"
@jincod
jincod / main.py
Last active September 22, 2015 04:06
A la Evernote with supporting markdown
from flask import Flask, request, abort, render_template
from bson import ObjectId
from flask.ext.pymongo import PyMongo
from datetime import datetime
import json
from flask import Response
app = Flask(__name__)
mongo = PyMongo(app)
@jincod
jincod / index.coffee
Created August 22, 2014 07:30
Internet magazine
app.post '/pay', (req, res) ->
payment =
account: req.body.account
value: req.body.value
transactionId: (Math.random() * 1e18).toString(36)
res.redirect "#{appUrl}/#{payment.account}/#{payment.value}/#{payment.transactionId}?returnUrl=#{returnUrl}"
app.post '/payment', (req, res) ->
input = req.body.account + req.body.value + req.body.transactionId + secureKey
sign = crypto.createHash("md5").update(input).digest("hex")