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 / 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
@kkurni
kkurni / TokenHandler.js
Last active December 11, 2015 21:28
Angular JS Factory for Token Handler which inject authorization header request. This must use in combination with my custom resource which modified based on 1.1.2 - https://gist.github.com/4662478
KK.factory('TokenHandler', ['$cookieStore', function ($cookieStore) {
var tokenHandler = {};
tokenHandler.setToken = function (newToken) {
$cookieStore.put("X-Authorization-Token", newToken);
console.log('set token ' + newToken);
};
tokenHandler.getToken = function () {
console.log('get cookie ' + $cookieStore.get("X-Authorization-Token"));
@kkurni
kkurni / kk-angular-resource-1.1.2
Last active December 11, 2015 21:28
AngularJS Resouce (1.1.2) with custom header params. Example to use. Authenticate.signIn(null,null, function (data, headers) { console.log(headers('x-token')); }, function(data, status, headers, config) { console.log('fail'); }, { 'Authorization': 'Basic dGVzdGtrMTNAdGVzdC5jb206cGFzc3dvcmQhMQ==' } );
'use strict';
/**
* @ngdoc overview
* @name ngResource
* @description
*/
/**
* @ngdoc object
@kkurni
kkurni / InjectHtmlService.js
Created January 30, 2013 07:37
Inject HTML Service Example with Authorization
'use strict';
SEEK.factory('InjectHtmlService', ['mobileRoot', '$http', 'TokenHandler', function (mobileRoot, $http, tokenHandler) {
var resource = {};
resource.injectHtml = function (url, success, error) {
$(document).on('submit', 'form', function () {
//add site
submitPost(mobileRoot + $(this).attr('action'));