This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useState} from 'react'; | |
import {nanoid} from 'nanoid'; | |
export type ItemWithId<T> = T & { id: string }; | |
export const useIdGeneratedItems = <T>(items: T[]): [ItemWithId<T>[], (items: ItemWithId<T>[]) => void] => { | |
const [itemsWithId, setItemsWithId] = useState(() => items.map(item => ({...item, id: nanoid()}))); | |
return [itemsWithId, setItemsWithId]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {WorkerHost} from '@nestjs/bullmq'; | |
import {Job} from 'bullmq'; | |
export class BatchWorkerHost extends WorkerHost { | |
private jobBatchCreationTime: Date; | |
private jobBatch: Job[]; | |
private jobBatchProcessPromise: Promise<void>; | |
private running: boolean = false; | |
private resolveJobBatchProcessPromise: () => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 10bis Notfiy Restaurant has opened | |
// @description Receive alert when a restaurant is opened | |
// @version 0.1 | |
// @include http*//www.10bis.co.il/next/Restaurants/menu/delivery/* | |
// @copyright Eran Betzalel | |
// ==/UserScript== | |
//====================================================================================================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name JIRA - Add Issues Sum Row | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Calculate the sum row for JIRA issues view | |
// @author You | |
// @match https://*.atlassian.net/issues/* | |
// @grant none | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ngrams(array, length) { | |
var ngramsArray = []; | |
for (var i = 0; i < array.length - (length - 1); i++) { | |
var subNgramsArray = []; | |
for (var j = 0; j < length; j++) { | |
subNgramsArray.push(array[i + j]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public decimal BytesToDecimal(byte[] buffer, int offset = 0) | |
{ | |
var decimalBits = new int[4]; | |
decimalBits[0] = buffer[offset + 0] | (buffer[offset + 1] << 8) | (buffer[offset + 2] << 16) | (buffer[offset + 3] << 24); | |
decimalBits[1] = buffer[offset + 4] | (buffer[offset + 5] << 8) | (buffer[offset + 6] << 16) | (buffer[offset + 7] << 24); | |
decimalBits[2] = buffer[offset + 8] | (buffer[offset + 9] << 8) | (buffer[offset + 10] << 16) | (buffer[offset + 11] << 24); | |
decimalBits[3] = buffer[offset + 12] | (buffer[offset + 13] << 8) | (buffer[offset + 14] << 16) | (buffer[offset + 15] << 24); | |
return new Decimal(decimalBits); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car | |
{ | |
public int CarId { get; set; } | |
public DateTime ManufactureDate { get; set; } | |
public decimal SomeDecimal { get; set; } | |
} | |
class DelimitedFileWriterExample | |
{ | |
static void Main() |