Skip to content

Instantly share code, notes, and snippets.

@dmorosinotto
dmorosinotto / icon.component.ts
Created October 24, 2024 04:50 — forked from jeffwhelpley/icon.component.ts
An awesome icon component I created for Angular
import { Component, Input, ElementRef, Renderer2, PLATFORM_ID } from '@angular/core';
import { isPlatformServer } from '@angular/common';
import { RequestResponseAdapter } from '@gethuman/adapters';
import { config } from '@gethuman/config';
import { GhWebState } from '@gethuman/state';
@Component({
selector: 'icon',
standalone: true,
template: ``, // no content for <icon></icon> since we are setting a mask-image
@dmorosinotto
dmorosinotto / encryption.util.ts
Last active September 28, 2024 00:20 — forked from renatoaraujoc/encryption.util.ts
EncryptionUtil in TSJS compatible in Browser/Node 🧐
//ORIGINAL CODE BY @renatoaraujoc https://gist.github.com/renatoaraujoc/11fab34592fd81c75800aa2934faa913
export class EncryptionUtil {
private static _textEncoder = new TextEncoder();
private static _textDecoder = new TextDecoder();
private static ENC_DEC_SIMPLE_CHARS =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_';
/**
* Simple synchronous encryption using `XOR` algorithm, returning only allowed characters.
* This method is fast but offers only low security. Supports UTF-8 characters.
@dmorosinotto
dmorosinotto / create-effect.ts
Last active July 31, 2023 13:28 — forked from e-oz/create-effect.ts
Helper function to handle async call and push value to Signal
//Helper function to handle async call (Observable generator with strategy + safe retry if error) to push value to Signal - useful for State Management with Signal
//READ MORE https://medium.com/@eugeniyoz/application-state-management-with-angular-signals-b9c8b3a3afd7
//ORIGINAL DOCS (NgRx component-store effect) https://ngrx.io/guide/component-store/effect#effect-method
import { isObservable, Observable, of, retry, Subject, Subscription } from 'rxjs';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { DestroyRef, inject } from '@angular/core';
/**
* This code is a copied `ComponentStore.effect()` method from NgRx and edited to:
* 1) be a standalone function;
const log = (tag: string) => tap(
next => console.log(`%c[${tag}: Next]`, 'color: #4CAF50;', next),
error => console.log(`%c${tag}: Error]`, 'color: #F44336;', error),
() => console.log(`%c[${tag}: Complete]`, 'color: #2196F3;')
);
@dmorosinotto
dmorosinotto / ngrxintro.md
Created July 21, 2017 12:57 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

/*!
An experiment in getting accurate visible viewport dimensions across devices
(c) 2012 Scott Jehl.
MIT/GPLv2 Licence
*/
function viewportSize(){
var test = document.createElement( "div" );
test.style.cssText = "position: fixed;top: 0;left: 0;bottom: 0;right: 0;";

node-websocketd

A lightweight node port of websocketd, originally written in go.

Usage

node-websocketd --port=8080 ./count.sh
public Func<IDictionary<string, object>, Task<object>> Invoke(Func<IDictionary<string, object>, object> executor)
{
Func<IDictionary<string, object>, Task<object>> invoker = null;
if (executor.Method.ReturnType != typeof (Task<object>))
{
invoker =
p =>
{
var task = new Task<object>(() => executor(p));
function backup() {
var request = require('request');
var util = require('util');
var date = new Date();
var year = date.getUTCFullYear();
var month = date.getUTCMonth() + 1;
var day = date.getUTCDate();
var body = {