Skip to content

Instantly share code, notes, and snippets.

@rpgmaker
rpgmaker / gist:5393368
Created April 16, 2013 04:34
Razor JS with attribute
<span class='test' id='_1_a'><span data-id='_2'></span></span>
<!--<script src='http://code.jquery.com/jquery-1.9.1.min.js'></script>-->
<script type='text/javascript'>
var Model = {},
ViewResponse = function () {
return {
@rpgmaker
rpgmaker / gist:5393381
Last active December 16, 2015 06:39
Razor JS with multiple expression attribute
<span special = '_1_a' class='test' id='_2_a'><span data-id='_3'></span></span>
<!--<script src='http://code.jquery.com/jquery-1.9.1.min.js'></script>-->
<script type='text/javascript'>
var Model = {},
ViewResponse = function () {
return {
@rpgmaker
rpgmaker / gist:5393481
Created April 16, 2013 05:02
Razor JS with String mixed with expression
<span>Hello<span data-id='_1'></span></span>
<!--<script src='http://code.jquery.com/jquery-1.9.1.min.js'></script>-->
<script type='text/javascript'>
var Model = {},
ViewResponse = function () {
return {
@rpgmaker
rpgmaker / gist:5401502
Created April 17, 2013 03:10
Razor JS with Email Detection
<span>[email protected]</span>
<!--<script src='http://code.jquery.com/jquery-1.9.1.min.js'></script>-->
<script type='text/javascript'>
var Model = {},
ViewResponse = function () {
return {
@rpgmaker
rpgmaker / gist:5463091
Created April 25, 2013 20:55
Razor JS Nested Blocks
@{
var bar = 'Bar';
var foo = 'Foo';
<span>@foo. @bar.</span>
@{
bar += ' Another';
foo += bar;
<p>@bar</p>
@{
<span>@foo. @bar.</span>
@rpgmaker
rpgmaker / gist:5463933
Created April 25, 2013 23:01
Razor JS with helper function
@{
<span>@specialRender('Olamide')</span>
<span>@specialRender('TJ')</span>
<span>@specialRender('Dara')</span>
}
@helper specialRender(x){
<span>Hello World to @x</span><br/>
}
Test("Regular Loop", () =>
{
var itemx = GetList(list, list2);
});
Test("Regular Loop2", () =>
{
var itemx = GetList2(list, list2);
});
@rpgmaker
rpgmaker / gist:7019767
Last active December 25, 2015 18:19
Test integer to string
static void Test(string name, Action action) {
var count = 10000;
var stopWatch = new Stopwatch();
stopWatch.Start();
for (var i = 0; i < count; i++)
action();
stopWatch.Stop();
Console.WriteLine("Iteration: {0}", count);
Console.WriteLine("Completed {0} in Avg {1} Milliseconds", name, stopWatch.ElapsedMilliseconds);
Console.WriteLine();
@rpgmaker
rpgmaker / gist:7079123
Created October 21, 2013 05:33
JSON Serializer First Draft
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
@rpgmaker
rpgmaker / gist:7479398
Created November 15, 2013 05:09
Int to string with goto
unsafe static string itoa_int32(int snum) {
char* s = stackalloc char[12];
char* ps = s;
int num1 = snum, num2, num3, div;
if (snum < 0) {
*ps++ = '-';
//Can't negate int min
if (snum == -2147483648)
return "-2147483648";
num1 = -num1;