Skip to content

Instantly share code, notes, and snippets.

@andriybuday
andriybuday / input-chosen-ember-component.js
Last active August 19, 2017 09:08
Integrating Chosen jQuery component with EmberJs and Bootstrap. This code works with Ember 1.2.0, jQuery 2.0.3, TwitterBootstrap 3.0 and Chosen 1.0.0.
App.InputChosenComponent = Ember.Component.extend({
init: function () {
this._super();
},
// settings
labelClass: 'col-sm-2',
label: 'Date',
inputContainerClass: 'col-sm-2',
inputClass: '',
didSaveRecord: function (record, data) {
if (data) {
this.didSaveRecordForHasManyItems(this, record.constructor, data, record);
}
this._super(record, data);
},
// Fixes introdution in ember-data.1.0.0.beta4 (see method "addUnsavedRecords" in Store)
// assume that "any unsaved records that are
// in a hasMany they won't be in the payload"
@andriybuday
andriybuday / Program.cs
Last active August 29, 2015 14:13
Integrating Edge.js into C# project
using System;
using EdgeJs;
namespace LearnEdgeJs
{
class Program
{
public void Start()
{
var func = Edge.Func(@"return require('../edgeEntryPoint.js')");
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using NUnit.Framework;
namespace YourSystem.Tests
using System;
using Microsoft.VisualStudio.TestTools.WebTesting;
namespace YourAppLoadTesting
{
public class AddCorrelationIdToReportPutRequest: WebTestPlugin
{
public string ApplyToRequestsThatContain { get; set; }
public string BodyStringParam { get; set; }
using System;
namespace LearnEvents
{
// Defining delegate type (similar to System.EventHandler)
delegate void SomeHandler(object sender, EventArgs e);
class Person
{
// Field-like event declared using keyword 'event'
@andriybuday
andriybuday / file-select.hbs
Created February 29, 2016 10:27
file-select component with Ember.JS
<input {{bind-attr accept=fileFilter}} class="file-input-hidden" type="file" />
{{action-button action='pressButton' type=type title=title icon=icon hidden=hidden disabled=disabled visible=visible}}
@andriybuday
andriybuday / UsingXLSX.js
Created February 29, 2016 10:43
Using XLSX library
// reading workbook from binary contents
var workbook = XLSX.read(excelBinaryContents, {type: 'binary'});
// retrieve properties of workbook (will be needed later)
var wbProps = workbook.Workbook.WBProps;
// get any particular worksheet by name
var worksheet = workbook.Sheets['Work Sheet Name'];
// get any cell
@andriybuday
andriybuday / UsingEPPlus.cs
Last active February 29, 2016 11:14
Using EPPlus
using (var excelPackage = new ExcelPackage(newFileInfo))
{
var ws = excelPackage.Workbook.Worksheets["Work Sheet Name"];
// do the stuff, here are some examples
var cellRange = ws.Cells[string.Format("{0}{1}:{0}{2}", "A", 2, 4)];
// merging cells
cellRange.Merge = true;
// setting value
cellRange.Value = "Any object that serves as cell value";
@andriybuday
andriybuday / 0 - ServiceHost.cs
Last active April 16, 2024 15:58
Microsoft.Extensions.DependencyInjection with OWIN Self-Hosted WebAPI
// ...
using Microsoft.Owin.Hosting;
// ...
public class ServiceHost
{
private IDisposable server = null;
const string baseAddress = "https://*:443";
public void Start()