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
export const getBase64 = (file: File): Promise<string> => | |
new Promise((resolve, reject) => { | |
const reader = new FileReader(); | |
reader.readAsDataURL(file); | |
reader.onload = function (): void { | |
resolve(reader.result?.toString()); | |
}; | |
reader.onerror = function (error): void { | |
reject(error); | |
}; |
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
/** | |
* Boosts up barcode read performance on Android | |
*/ | |
const RNCameraProps: RNCameraProps = {}; | |
if (Platform.OS === OS.IOS) { | |
RNCameraProps.onBarCodeRead = ({ data }) => { | |
console.log(data); | |
}; | |
} else { |
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
# It formats disk2 in format FAT32 | |
# In order to check your disk name run: diskutil list | |
sudo diskutil eraseDisk FAT32 MYSD MBRFormat /dev/disk2 |
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
/* OUTPUTS ALL STATUSES WITH LATEST ITEM, 4 STATUSES = 4 ITEMS IN OUTPUT */ | |
SELECT m1.* | |
FROM stats m1 | |
LEFT JOIN stats m2 | |
ON (m1.status = m2.status AND m1.created_at < m2.created_at) | |
WHERE m2.id IS NULL; |
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
const alreadySearched = useMemo( | |
() => | |
[...history] | |
.slice(0, MAX_ITEMS_PER_PAGE) | |
.filter((element) => | |
items.some((item) => | |
item.name.toLowerCase().includes(element.toLowerCase()), | |
), | |
), | |
[history, items], |
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
const hasValues = Object.values({ | |
...sample, | |
}).some((val) => !isEmpty(val)); |
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
/** | |
* Mocks new Date() in jest | |
*/ | |
const mockDate: any = new Date(1466424490000); | |
const spy = jest.spyOn(global, 'Date').mockImplementation(() => mockDate); | |
expect(YourTestResult.date).toEqual(new Date(1466424490000)); | |
spy.mockRestore(); |