Skip to content

Instantly share code, notes, and snippets.

View kkurni's full-sized avatar

Kurniawan Kurniawan kkurni

  • Microsoft
  • Redmond
View GitHub Profile
@kkurni
kkurni / DynamicModelMapper
Last active January 1, 2016 19:48
Dynamic Model mapper will convert dictionary<string,string> into proper object, it is very useful for razor engine. for example you can define Model.Parent.Child as a key and you can parse it to your favourite razor engine
public DynamicModel Convert(Dictionary<string, string> dictionary, bool isStrictGet)
{
var customDynamicObject = new DynamicModel(isStrictGet: isStrictGet);
foreach (var key in dictionary.Keys)
{
AddValueToExpandoRecursive(customDynamicObject, key, dictionary[key], isStrictGet);
}
return customDynamicObject;
@kkurni
kkurni / DynamicModel
Last active January 1, 2016 23:09
This is Dynamic custom model t which useful to create object graph where you want your object to be very flexible such as in razor template use cases
public class DynamicModel : DynamicObject
{
private readonly bool _isStrictGet;
public IDictionary<string, object> _dict;
public DynamicModel(string objectName = null, IDictionary<string, object> dict = null, bool isStrictGet = false)
{
ObjectName = objectName;
_dict = dict ?? new Dictionary<string, object>();
_isStrictGet = isStrictGet;
@kkurni
kkurni / scroll-helper.js
Last active August 29, 2015 13:59
scroll helper will recursively try to scroll into your element. this will be very useful in angularjs
'use strict';
commonLib.factory('scrollHelper', ['$timeout', function ($timeout) {
//scroll to element recursively until found
function scrollToElement(scrollToId, maxRetry) {
var counter = 0;
function tryScroll() {
counter ++;
@kkurni
kkurni / errorceptionHandler.js
Created May 1, 2014 12:44
errorception handler for angularjs
app.factory('$exceptionHandler', function ($log) {
return function (exception, cause) {
exception.message += ' (caused by "' + cause + '")';
$log.error(exception);
throw exception;
};
});
@kkurni
kkurni / angular-scroll.js
Created May 21, 2014 05:53
angular-scroll with duration which work with accordion mobile scroll
/* customised from angular-scroll lib, to support scrolling to moving element... */
/**
* x is a value between 0 and 1, indicating where in the animation you are.
*/
var duScrollDefaultEasing = function (x) {
if (x < 0.5) {
return Math.pow(x * 2, 2) / 2;
}
return 1 - Math.pow((1 - x) * 2, 2) / 2;
@kkurni
kkurni / job.me
Created May 25, 2014 11:15 — forked from MPiunti/job.me
= jOB.me =
As a global player in IT, Reply is shaped over a network organizational model which is actually spread over 3 continents. The group partnership is natively conceived over multidisciplinary skills and resources, tackling multifaceted markets, technologies and IT domains thanks to the tremendous competencies of its employees. The same competencies which are are well suited and represented over _TamTamy_, more and more constituting the real backbone, the _Ark of the Covenant_ where each of the corporate assets dwell.
*jOB.me* is conceived as a *social crawler*, aiming at promoting and reinforcing the links between different companies inside the group: its basic idea is that knowledge, people and their relationships stand as _FIRST CLASS ENTITIES_ inside the corporate network. jOB.me promotes the organizational structure to scale horizontally - in-the-large - towards an evolutionary network where processes, organizations and people are oriented to the natural diffusion and exchange of knowledge and c
= Car manufacturers 2013
This is a graph of all the major car manufacturers and their earnings in 2013, alongside all of their main suppliers.
It also shows the relationships between the various manufactures: cooperations, jointventuress and stock ownership. and the type of those
relationships.(For example a cooperation can be of the type: research/development)
//hide
01:01:19 - Execute Reader 1
01:01:19 - Execute Reader 2
01:01:49 - ERROR : System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 35 - An internal exception was caught) ---> System.ComponentModel.Win32Exception: The wait operation timed out
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) in ...src\System.Data.SqlClient\System\Data\SqlClient\SqlConnection.cs:line 1848
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) in ...src\System.Data.SqlClient\System\Data\SqlClient\SqlInternalConnection.cs:line 786
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean
using System;
using System.Data;
using System.Data.SqlClient;
public class Program
{
public static void Main()
{
Console.WriteLine("Run");
TestConnectionString("your connection string");