Skip to content

Instantly share code, notes, and snippets.

@lushiyun
lushiyun / work-with-multiple-github-accounts.md
Created December 21, 2022 19:08 — forked from rahularity/work-with-multiple-github-accounts.md
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
@lushiyun
lushiyun / global-custom-properties.css
Last active December 15, 2022 15:21
Common global CSS custom properties
:root {
font-size: 16px;
--space: 4px;
--space-2x: 8px;
--space-4x: 16px;
--space-8x: 32px;
--space-16x: 64px;
--space-24x: 96px;
--space-32x: 128px;
/*
1. Use a more-intuitive box-sizing model.
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
@lushiyun
lushiyun / GLSL-Noise.md
Created November 27, 2022 05:11 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
... // omitted other imports
import { selectUnreadMessages } from '../messages/messagesSlice'
const TeamListItem = ({ team }) => {
...
const numOfUnreads = useSelector((state) =>
// src/features/messages/messagesSlice.js
... // omitted other imports
import { selectTeamById } from '../teams/teamsSlice'
import { isAfter, parseISO, subYears } from 'date-fns'
export const selectUnreadMessages = createSelector(
[selectMessagesByTeam, selectTeamById],
(messages, team) => {
const lastReadAt = parseISO(team.lastReadAt) || subYears(Date.now(), 1)
... // omitted other imports
import { selectMessagesByTeam } from './messagesSlice'
import { useSelector } from 'react-redux'
import MessageItem from './MessageItem'
const MessagesList = () => {
...
const messages = useSelector((state) => selectMessagesByTeam(state, teamId))
// src/features/messages/messagesSlice.js
...
export const { selectAll: selectAllMessages } = messagesAdapter.getSelectors(
(state) => state.messages
)
export const selectMessagesByTeam = createSelector(
[selectAllMessages, (state, teamId) => teamId],
// src/features/messages/messagesSlice.js
... // omitted imports
const messagesAdapter = createEntityAdapter()
const initialState = messagesAdapter.getInitialState({
...
})
# app/channels/messages_channel.rb
class MessagesChannel < ApplicationCable::Channel
...
def receive(data)
...
MessageRelayJob.perform_later(message)
end
...
end