Skip to content

Instantly share code, notes, and snippets.

View angelo510's full-sized avatar
🏠
Working from home

Angelo ^_^ angelo510

🏠
Working from home
  • Independent Freelancer
View GitHub Profile
@angelo510
angelo510 / component.ts
Created October 14, 2019 16:43
Example of Angular component for best rxjs practice
import { Component, forwardRef, Input } from "@angular/core";
import { NG_VALUE_ACCESSOR } from "@angular/forms";
import { DateTime } from "luxon";
import { BehaviorSubject, combineLatest, of } from "rxjs";
import { filter, map, shareReplay, startWith, switchMap } from "rxjs/operators";
import { AppointmentsService } from "src/appointments/appointments.service";
import { AppointmentSlot } from "src/appointments/fields/appointment-slot.model";
import { Day } from "src/core/day.model";
import { BaseFieldComponent } from "src/core/forms/base-field.component";
import { SitesService } from "src/core/sites";
@angelo510
angelo510 / dropdown.component.scss
Created October 14, 2019 16:28
Styles for Dropdown Component (SCSS)
@import "../../app/variables";
:host {
display: block;
min-width: 8rem;
select,
ng-select ::ng-deep .ng-select-container {
width: 100%;
min-height: 2.5rem;
@angelo510
angelo510 / dropdown.component.html
Created October 14, 2019 16:27
Dropdown Component Angular Template
<mr-field-container
#container
[fieldId]="fieldId"
[label]="label"
[description]="description"
>
<ng-select
*ngIf="hasItems; else staticOptions"
[labelForId]="container.fieldId"
[attr.aria-describedby]="container.descriptionId"
@angelo510
angelo510 / dropdown.component.ts
Created October 14, 2019 16:26
DropdownComponent extended from BaseFieldComponent
import {
Component,
ContentChildren,
EventEmitter,
forwardRef,
Input,
OnDestroy,
Output,
QueryList,
} from "@angular/core";
@angelo510
angelo510 / base-field.component.ts
Created October 14, 2019 16:24
BaseFieldComponent with ControlValueAccessor for global field definition
import { EventEmitter, Input, Output } from "@angular/core";
import { ControlValueAccessor } from "@angular/forms";
import { parseBooleanAttribute } from "src/utils";
export abstract class BaseFieldComponent<T> implements ControlValueAccessor {
@Input() public fieldId?: string;
@Input() public label?: string;
@Input() public description?: string;
@Input() public value: T | null = null;
@angelo510
angelo510 / test.rb
Last active October 11, 2017 20:39
inputProducts = gets
total = 0
products = {
"A" => { "1" => 2.00, "4" => 7.00 },
"B" => { "1" => 12.00 },
"C" => { "1" => 1.25, "6" => 6.00 },
"D" => { "1" => 0.15 }
}
inputArray = inputProducts.split('') # input products
counts = Hash.new # number of item
@angelo510
angelo510 / actions.js
Last active August 28, 2017 18:57
React+Redux+Saga Code Example
import {
SET_CHANNEL_FILTER,
SET_CHANNEL_TYPE,
SET_CONNECTIONS_LIST,
TOGGLE_ADD_CONNECTION_DIALOG,
FETCH_SOCIAL_URL,
CONNECTION_CALLBACK,
SET_SOCIAL_URLS,
REMOVE_CONNECTION,
SET_SUB_CALLBACK,
@angelo510
angelo510 / clientController.js
Created January 24, 2017 15:20
AngularJS Controller file which controls Guacamole
/**
* The controller for the page used to connect to a connection or balancing group.
*/
angular.module('client').controller('clientController', ['$scope', '$routeParams', '$injector',
function clientController($scope, $routeParams, $injector) {
// Required types
var ManagedClient = $injector.get('ManagedClient');
var ManagedClientState = $injector.get('ManagedClientState');
var ManagedFilesystem = $injector.get('ManagedFilesystem');
@angelo510
angelo510 / Client.html
Created January 24, 2017 15:14
AngularJS + Guacamole
<guac-viewport>
<!-- Client view -->
<div class="client-view">
<div class="client-view-content">
<!-- Central portion of view -->
<div class="client-body" guac-touch-drag="clientDrag" guac-touch-pinch="clientPinch">
<!-- Client -->
@angelo510
angelo510 / salesforce_snippet2
Created January 23, 2017 18:08
salesforce_snippet2_model
<?php
namespace Xsolve\SalesforceClient\Model;
use JMS\Serializer\Annotation as JMS;
use Xsolve\SalesforceClient\Enum\AbstractSObjectType;
use Xsolve\SalesforceClient\Enum\SObjectType;
class Account extends AbstractSObject
{
/**
* @var bool|null
* @JMS\Type("boolean")