Skip to content

Instantly share code, notes, and snippets.

View benmotyka's full-sized avatar

benmotyka benmotyka

View GitHub Profile
@benmotyka
benmotyka / aws-ec2-instances.sh
Created May 16, 2023 17:07
AWS CLI list all ec2 instances (name, ip, ssh key) in table format
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[*].[Tags[?Key==`Name`].Value,PrivateIpAddress,KeyName,`--------------------`]' --output table
function debounce(func, timeINMS) {
let timeout;
return function () {
clearTimeout(timeout);
timeout = setTimeout(func, timeINMS);
};
}
let debouncedHello = debounce(() => console.log("say hello", Date.now()), 1000);
@benmotyka
benmotyka / index.ts
Created February 12, 2023 23:12
React Native check if user swiped
<View
onTouchStart={e=> this.touchY = e.nativeEvent.pageY}
onTouchEnd={e => {
if (this.touchY - e.nativeEvent.pageY > 20)
console.log('Swiped up')
}}
style={{height: 300, backgroundColor: '#ccc'}}
/>
@benmotyka
benmotyka / useCheckOnline.js
Last active May 16, 2023 17:05
Simple React hook that checks if user is online
useEffect(() => {
window.addEventListener('offline', () => {
setOnlineStatus(false);
});
window.addEventListener('online', () => {
setOnlineStatus(true);
});
return () => {
window.removeEventListener('offline', () => {
setOnlineStatus(false);