Skip to content

Instantly share code, notes, and snippets.

View vcardins's full-sized avatar

Victor Cardins vcardins

  • Vancouver, BC, Canada
View GitHub Profile
export namespace TsIonRangeSlider
{
let pluginCount = 0;
export interface ISlider {
destroy(): void;
reset(): void;
update(option: IonRangeSliderOptions): void;
}
@vcardins
vcardins / automapper.ts
Last active March 30, 2020 22:04
AutoMapper
// usage: AutoMapper.map<UserProfile>(user, user.profile);
export class AutoMapper {
static map<TSource>(sourceObj: TSource, ...args: any[]): void {
const initializers = args.filter(Boolean)
if (!initializers?.length) {
return;
}
const sourceObjectProps = Object.getOwnPropertyNames(sourceObj);
@vcardins
vcardins / cloudSettings
Created February 26, 2019 07:00
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-02-26T07:00:56.825Z","extensionVersion":"v3.2.5"}
@vcardins
vcardins / GlobalState.cs
Last active May 8, 2018 23:56
Multiple contexts BOT sample
using System.Collections.Generic;
namespace MyBot.Api.Bot
{
public class GlobalState : Dictionary<string, object>
{
private const string UpdateProfileKey = "UpdateProfile";
private const string CreateProjectKey = "CreateProject";
public GlobalState()
...
render() : JSX.Element {
const { isLoading, className, children, actions = [], filters = []} = this.props;
const classNames = ['panel-element', className].filter(Boolean).join(' ');
return (
<ReflexElement className={classNames} >
<div className="panel-body">
{isLoading && <Loader active inline /> }
{!isLoading && children }
</div>
@vcardins
vcardins / get-rules.js
Created May 17, 2017 08:05
Location ranking filtering ( e.g 4,8-120,2,135-172)
getRules (query = '') {
const getValueRule = (values = []) => (val) => !values.length ? undefined : values.indexOf(val) > -1;
const getIntervalRule = (range = []) => (val) => !range.length ? undefined : val >= range[0] && val <= range[1];
const rules = [];
if (!arr.length) {
return rules;
}
// Split query by common and extract rules units
const values = query.split(',').filter(Boolean);
@vcardins
vcardins / App.tsx
Last active May 5, 2017 16:50
Baobab branch decorator issue
import * as React from 'react';
import { root, branch } from 'baobab-react/higher-order';
// Here is the problem. It does not return the data stored in the cursor ['user', 'model'] but undefined instead
// if I have only user: ['user'], it returns the user branch { user: { model: { ... }}, but then I have to deconstruct
// const { model: user = {} ) = this.props.user to get the actual data
@branch({
user: ['user', 'model'],
})
class App extends BaseComponent<Props, State> {
angular.module('app.core')
.config(configure);
/* @ngInject */
function configure(routerHelperProvider, SETTINGS) {
routerHelperProvider.configure({docTitle: SETTINGS.title + ': '});
}
@vcardins
vcardins / app.layout.js
Last active February 15, 2016 02:49
Angular Realtime Update
(function() {
'use strict';
angular
.module('app.layout')
.run(appRun);
//appRun.$inject = ['routerHelper', 'RealTime', 'Chat'];
/* @ngInject */
function appRun(routerHelper) {
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using Microsoft.AspNet.SignalR;
using Omu.ValueInjecter;
using SimpleInjector;
using TechsApp.Core.Extensions.Membership;
using TechsApp.Core.Interfaces.Data;