Skip to content

Instantly share code, notes, and snippets.

View IcodeNet's full-sized avatar
😀

Byron Thanopoulos IcodeNet

😀
View GitHub Profile
@IcodeNet
IcodeNet / Umbraco Razor Script Retrieve CheckBox List Selected Values
Created May 1, 2012 10:13
Umbraco Razor Script Retrieve CheckBox List Selected Values
var optionList = DynamicModel.TypeOfRoom; // TypeOfRoom is the check-box List
//Multiple Checkboxes selected
if (DynamicModel.TypeOfRoom.GetType() == typeof(Umbraco.Framework.Dynamics.BendyObject)){
var options = DynamicModel.TypeOfRoom.__KeyedChildren;
foreach(var kv in options){
RoomType is -- > @kv.Value
}
}
@IcodeNet
IcodeNet / MVC SS
Created October 10, 2012 07:06
Oauth and SS
Mvc 3.0 project that hosts my Services using Service stack
Same MVc 3.0 project that holds my controllers responsible for generating the Request Token and Access Token for Oauth authentication
In the same MVC project I have an AccountController that my secure services are directed to its “login” action through [Authenticate(HtmlRedirect = "/account/login")]
Currently the RequestTokenController returns a hard coded “code” for all requests and the AccessTokenController a hardcoded “access_code”
They achieve this through simple redirection to the redirect_uri which is <baseURL>/auth/<provider>
As in the following
Response.Redirect(redirect_uri + "?code=4512391789087");
@IcodeNet
IcodeNet / gist:3863962
Created October 10, 2012 08:12
Stop all cassini instances. Stop all devwebserver.exe instances
taskkill /IM WebDev.WebServer20.exe /F
taskkill /IM WebDev.WebServer40.exe /F
/* in large VS solutions we might need to start loads of WebDev instances.
The above script will kill all*/
@IcodeNet
IcodeNet / Delete all the bin and obj folders in a solution 2012:
Created November 28, 2012 12:56
Delete all the bin and obj folders in a solution 2012
Delete all the bin and obj folders in a solution 2012:
Right-click on the solution in Solution Explorer
Open Command Prompt
Run powershell
Paste and run :
Get-ChildItem -include bin,obj -recu -Force | remove-item -force -recurse
@IcodeNet
IcodeNet / binding-dump.js
Created January 21, 2014 07:46
binding-dump.js will dump the current Knockoutjs model
// Usage in HTML
// <div data-bind="dump: $data"></div>
// <div data-bind="dump: $root.results"></div> (if results was an observable/observableArray)
// <div data-bind="dump: $root.results()[0].someProperty"></div> (first items property)
ko.bindingHandlers.dump = {
init: function (element, valueAccessor, allBindingsAccessor, viewmodel, bindingContext) {
var context = valueAccessor();
var allBindings = allBindingsAccessor();
var pre = document.createElement('pre');
@IcodeNet
IcodeNet / binding-typeahead.js
Created January 21, 2014 07:53
twitter Type ahead Binding handler
ko.bindingHandlers.typeahead = {
init: function (element, valueAccessor) {
var observableSource = valueAccessor();
var elem = $(element)[0];
var options = {
source: ko.utils.unwrapObservable(observableSource),
items : 4
};
@IcodeNet
IcodeNet / HookTwitterTypeAheadWithKnockout.js
Last active January 3, 2016 23:38
How do I hook up twitter type ahead and knockoutJS?
//************* HTML *****************************
<input class="typeahead form-control"
type="text"
placeholder="Fnet User Lookup">
//************* JS *****************************
$('.typeahead').typeahead({
remote: {
url: myApp.rootPath + 'user/AutocompleteUser?query=%query',
@IcodeNet
IcodeNet / PageUsingChosen.html
Created January 21, 2014 08:06
How do I use Knockout and Chosen?
<select data-placeholder="Select item" data-bind="chosen: { chosenOption: { allow_single_deselect: true }, source: clusters, valueProp: 'Id', selectedValue: selectedCluster, displayProp: 'Name' }"></select>
<!--
where clusters is an observable array of objects with properties Id,Name
source: clusters,
valueProp: 'Id',
selectedValue: selectedCluster,
displayProp: 'Name'
-->
@IcodeNet
IcodeNet / viewModelHelper.js
Created January 21, 2014 08:12
How do I encapsulate in Knockout all the POST, GET, DELETE operations? ViewModelHelper
window.myApp = window.myApp || {};
(function (ns) {
var rootPath;
ns.rootPath = rootPath;
}(window.myApp));
(function (ns) {
var viewModelHelper = function () {
@IcodeNet
IcodeNet / plugins.js
Created February 25, 2015 11:39
// Avoid `console` errors in browsers that lack a console.
// Avoid `console` errors in browsers that lack a console.
(function() {
var method;
var noop = function () {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeStamp', 'trace', 'warn'
];