Skip to content

Instantly share code, notes, and snippets.

View YonathanMeguira's full-sized avatar
🤩
Happy

Yonathan Meguira YonathanMeguira

🤩
Happy
View GitHub Profile
@YonathanMeguira
YonathanMeguira / gist:934ba151a5e866b4b710fd53119c59e8
Created February 23, 2022 10:38
no_check_fk_restriction.sql
USE AdventureWorks2012;
GO
ALTER TABLE Purchasing.PurchaseOrderHeader
NOCHECK CONSTRAINT FK_PurchaseOrderHeader_Employee_EmployeeID;
GO
@YonathanMeguira
YonathanMeguira / user.java
Last active January 25, 2022 16:59
Dato-Sync Service common data model
/** here is the model sync service is expecting to receive.**/
package com.datorama.core.dto.admin.gdo;
import java.util.Collection;
import com.datorama.core.dto.admin.UserDto;
public class GdoUser {
private final Integer id;
private final String email;
private final String firstName;
private final String lastName;
private final Integer language;
interface Response {
requestId: string;
// status could be for instance: Request Approved, or Request Failed to approve because it does not exist anymore.
// status is either a success message or an error message that explains why the operation (deny/ approve / revoke) failed.
status: string;
email: string;
}
/**
@YonathanMeguira
YonathanMeguira / sorting.ts
Created January 20, 2021 16:07
AG-grid: sorting for custom rendered colums
const myColDefs = [{
headerName: 'Header Name',
sortable: true,
cellRenderer: 'propName',
comparator: (valueA: any, valueB: any, nodeA: RowNode, nodeB: RowNode, isInverted: boolean) =>
sortColumnAlphabetically<User>('status', nodeA, nodeB)
}]
export function sortColumnAlphabetically<T>(key: keyof T, nodeA: any, nodeB: any): number {
const [valueA, valueB] = [nodeA.data[key], nodeB.data[key]];
const siteHeaderElement = .nativeElement;
const customClasses = localStorage.getItem('custom');
.brand-name{color: blue}
// regex to get array of classname
const classNames = ['NP1', 'NP2', 'LC'];
function getElement(className): ElementRef {
const keepListening$ = new BehaviorSubject<boolean>(true);
// do whatever with your operator
myOperator$.pipe(takeUntil(keepListening$)).subscribe(gotResponse => {
// do whatever
if (gotResponse) {
keepListening$.next(false);
}
})
const event = fromEvent(window, 'storage || onStorage')
.pipe(filter((values: any[]) => // get right key, filter);
// returns the value of amplitude in local storage
event.pipe(pairwise(), take(1)).subscribe(([prev, curr]) => {
if (prev && !curr) {
// amplitude just sent all the events
sendEventsFromSession()
}
})
export class CachedAccount {
id: string;
config: string;
enableWhiteLabelUi: boolean;
isSsoEnabled: boolean;
ssoLogoutRedirectURL: string;
constructor({id, config, enableWhiteLabelUi, isSsoEnabled, ssoLogoutRedirectURL}: Account) {
@YonathanMeguira
YonathanMeguira / agGrid.ts
Last active December 22, 2020 15:58
agrid-export-api-for-humans
// in your component or wherever your grid options are defined
// reference to the grid element
@ViewChild(DatoGridControllerComponent, { static: true }) gridController: DatoGridControllerComponent;
gridOptions: DatoGridOptions = {
…gridOptions,
onSelectionChanged: () => this.onSelectionChange(),
onRowDoubleClicked: ({ data }: RowDoubleClickedEvent) => this.editUser(data),
exportGrid: () => this.exportGrid(), // ==> callback for the export
"Server Error. 4158811\norg.hibernate.exception.SQLGrammarException: could not extract ResultSet\n\tat org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123)\n\tat org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)\n\tat org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)\n\tat org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)\n\tat org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:91)\n\tat org.hibernate.loader.Loader.getResultSet(Loader.java:2066)\n\tat org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1863)\n\tat org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1839)\n\tat org.hibernate.loader.Loader.doQuery(Loader.java:910)\n\tat org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:355)\n\tat org.hibernate.loader.Loader.doList(Loader.java:255