Skip to content

Instantly share code, notes, and snippets.

View jbutko's full-sized avatar

Jozef Butko jbutko

View GitHub Profile
@jbutko
jbutko / detect-scroll.js
Created September 10, 2018 06:28
React Native: Detect ScrollView has reached the end
import React from 'react';
import {ScrollView, Text} from 'react-native';
const isCloseToBottom = ({layoutMeasurement, contentOffset, contentSize}) => {
const paddingToBottom = 20;
return layoutMeasurement.height + contentOffset.y >=
contentSize.height - paddingToBottom;
};
const MyCoolScrollViewComponent = ({enableSomeButton}) => (
@jbutko
jbutko / style.css
Created September 26, 2013 18:43
CSS, Safari: Target only Safari browser
@media screen and (-webkit-min-device-pixel-ratio:0) {
/* Safari and Chrome */
.flex-direction-nav-featured a{
margin-top: 4%;
}
/* Safari only override */
::i-block-chrome,.flex-direction-nav-featured a{
margin-top: 5%;
}
@jbutko
jbutko / readme.MD
Created April 5, 2017 18:18
Socket.io: broadcasting to (not only) rooms

Send to the sender and noone else

socket.emit('hello', msg);

Send to everyone including the sender(if the sender is in the room) in the room "my room"

io.to('my room').emit('hello', msg);

Send to everyone except the sender(if the sender is in the room) in the room "my room"

socket.broadcast.to('my room').emit('hello', msg);

Send to everyone in every room, including the sender

@jbutko
jbutko / bash.sh
Last active February 16, 2024 11:59
Unix commands
# 10 biggest files
sudo du -a /var | sort -n -r | head -n 10
# check available space
df -h
# check biggest folders/directories in GB
du -hsx * | sort -rh | head -10
# create user and assign password
@jbutko
jbutko / handle-file-download-react-axios.js
Last active January 31, 2024 04:48
React, JS, Axios: Download blob file (PDF...)
import axios, { AxiosResponse } from 'axios';
import { get } from 'lodash-es';
const rest = axios.create({
baseURL: 'some base URL goes here',
});
// this one send file as Blob type
const getPdf = () => (
rest.get(`/get-pdf`, {
@jbutko
jbutko / unix-digitalocean-spaces-s3cmd.md
Last active July 18, 2023 12:53
Unix (ubuntu): setup and use s3cmd to upload files to digitalocean spaces
@jbutko
jbutko / style.css
Created January 18, 2015 20:14
#CSS: Show three dots (...) at the end of the line
span {
display:inline-block;
width:180px;
white-space: nowrap;
overflow:hidden !important;
text-overflow: ellipsis;
}
/* From http://stackoverflow.com/questions/11426275/how-can-i-show-dots-in-a-span-with-hidden-overflow*/
@jbutko
jbutko / readme.MD
Last active January 10, 2023 10:32
How to unregister and register gitlab-runner on ubuntu

Unregister runnning runner

UI way:

  1. Delete runner from UI dashboard:
  1. run sudo gitlab-runner verify --delete command, dead runners will be deleted

Bash way:

  1. SSH to your server
@jbutko
jbutko / resize.sh
Last active December 14, 2022 10:02
Resize swap
# Resize Swap to 8GB
# Turn swap off
# This moves stuff in swap to the main memory and might take several minutes
sudo swapoff -a
# if it won't work issue:
# sudo /sbin/swapoff
# Create an empty swapfile
# Note that "1G" is basically just the unit and count is an integer.
# Together, they define the size. In this case 8GB.
@jbutko
jbutko / husky-lint-staged-eslint-prettier-pre-commit.md
Last active August 2, 2022 15:22
Husky and Lint-staged pre-commit hook to lint code with ESLint and format code with Prettier before commit
  1. install deps: yarn add -D husky lint-staged is-ci
  2. configure husky pre-commit hook:
npm set-script prepare "husky install"
npm run prepare
npx husky add .husky/pre-commit "npm run pre-commit"
  1. edit npm prepare script: "prepare": "is-ci || husky install"
  2. add pre-commit script to package.json scripts section: