Skip to content

Instantly share code, notes, and snippets.

View tetrashine's full-sized avatar

louisz tetrashine

View GitHub Profile
public class Organisation
{
public const string Name = "App:Organisation";
public string Email { get; set; } = String.Empty;
public string Phone { get; set; } = String.Empty;
}
...
public class TestController : Controller
{
private IConfiguration _configuration;
public TestController(IConfiguration configuration)
{
_configuration = configuration;
Debug.WriteLine($"Config (MyKey): {_configuration.GetSection("MyKey")}");
Debug.WriteLine($"Config (App:Name): {_configuration.GetSection("App:Name")}");
Debug.WriteLine($"Config (App:Organisation:Email): {_configuration.GetSection("App:Organisation:Email")}");
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"MyKey": "My appsettings key value",
"App": {
const cqlHoc = (Component) => {
return (props) => {
const { layer, attr, remainingProps } = props;
const generateCql = (attr, values) => `${attr} IN (${values.map(_ => `'${_}'`).join(',')})`;
return <Component
{...remainingProps}
onChange={(selected) => {
layer.setCql(generateCql(attr, selected));
}}
function DisplayPosts({posts}) {
return (
<ul>
{ posts.map(({id, text}) => (<li key={id}>{text}</li>)) }
</ul>
);
}
function loaderHoc(Component) {
return class LoaderComponent extends React.Component {
const subCategoryHoc = (Component) => {
return (props) => {
const { onCountryChange, onCityChange } = props;
const [selectedOption, setSelectedOption] = useState("canada");
const cities = {
"canada": ["Toronto", "Quebec City", "Vancouver"],
"china": ["Shanghai", "Beijing", "Guangzhou"],
"japan": ["Sapporo", "Tokyo", "Yokohama"],
"us": ["New York", "Los Angeles", "Chicago"],
};
<configProtectedData defaultProvider="defaultProvider">
<providers>
<add name="defaultProvider" type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=4.0.30319.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" keyContainerName="Project_KeyContainer" useMachineContainer="true" />
</providers>
</configProtectedData>
@tetrashine
tetrashine / wpp.xml
Created May 7, 2021 19:39
Web Publishing Profile xml - runCommand
<Target Name="executeEncryptionInHost" AfterTargets="AddIisSettingAndFileContentsToSourceManifest">
<Message Text="Executing encryption batch script" />
<ItemGroup>
<MsDeploySourceManifest Include="runCommand">
<path>E:\scripts\run_encrypt.bat</path>
</MsDeploySourceManifest>
</ItemGroup>
</Target>
@tetrashine
tetrashine / findLargestRectangle.js
Last active April 17, 2021 13:40
Find largest rectangle in a GIS polygon using TurfJS
runByFeatures(features) {
if (features.type !== "Feature") return undefined;
let polygon = turf.polygon(features.geometry.coordinates);
const unitsOption = {units: 'kilometers'};
let polyline, length, bbox, percentage1, percentage2, fraction, point1, point2, bearing;
let point1a, point1b, point2a, point2b, line1, line2;
let largest, diagonalLength;
polyline = turf.polygonToLineString(polygon);
@tetrashine
tetrashine / cluster.sql
Created March 15, 2021 18:52
Cluster.sql
SELECT B.geom, COUNT(A.id) as count FROM
(
SELECT (ST_SquareGrid(0.1,
ST_GeomFromText('POLYGON((103.605655941305 1.15876249278089,103.605655941305 1.47078321442792,104.088483621717 1.47078321442792,104.088483621717 1.15876249278089,103.605655941305 1.15876249278089))', 4326)
)).*) B
LEFT JOIN cluster_locations A ON ST_Intersects(A.geom, B.geom)
GROUP BY B.geom