This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sortBy = function(arr, ...sortByArgs){ | |
arr.sort(function(a,b){ | |
var sortResult = 0; | |
sortByArgs.forEach(function(arg){ | |
if (sortResult != 0) return; | |
if(Object.values(arg)[0] == 'desc'){ | |
var propName = Object.keys(arg)[0]; | |
if (a[propName] > b[propName]){ | |
sortResult = -1; | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<DevicesConfiguration> | |
<devices> | |
<device type="SM_G920I###6.0.1"> | |
<touchActivities> | |
<touchActivity type="ToggleFlightMode"> | |
<points> | |
<point x="500" y="1800" id="1"/> | |
<point x="1300" y="430" id="2"/> | |
</points> | |
</touchActivity> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// ConfigurationElement with additional Id property | |
/// | |
public abstract class IdentifiableConfigurationElement : ConfigurationElement | |
{ | |
public virtual string Id { get; } | |
} | |
/// | |
/// Generic ConfigurationElementCollection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configSections> | |
<section name="DevicesConfiguration" type="MyNamespace.DevicesConfigurationSection, MyNamespace" /> | |
</configSections> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var devicesConfiguration = System.Configuration.ConfigurationManager | |
.GetSection("DevicesConfiguration") as DevicesConfigurationSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DevicesConfigurationSection : ConfigurationSection | |
{ | |
[ConfigurationProperty("devices")] | |
[ConfigurationCollection(typeof(DeviceConfigElement), AddItemName = "device", CollectionType = ConfigurationElementCollectionType.BasicMap)] | |
public ConfigurationElementCollection<DeviceConfigElement> Devices => base["devices"] as ConfigurationElementCollection<DeviceConfigElement>; | |
} | |
public class DeviceConfigElement : IdentifiableConfigurationElement | |
{ | |
public override string Id => Type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const movies = [ | |
{ | |
"Title": "Inception", | |
"Year": "2010", | |
"Director": "Christopher Nolan" | |
}, | |
{ | |
"Title": "Interstellar", | |
"Year": "2014", | |
"Director": "Christopher Nolan" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.groupBy = function(field){ | |
let groupedArr = []; | |
this.forEach(function(e){ | |
//look for an existent group | |
let group = groupedArr.find(g => g['field'] === e[field]); | |
if (group == undefined){ | |
//add new group if it doesn't exist | |
group = {field: e[field], groupList: []}; | |
groupedArr.push(group); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src='https://unpkg.com/sweetalert2@7.17.0/dist/sweetalert2.all.js'></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button id='swal-popup-example-button'>Click Me</button> |