Skip to content

Instantly share code, notes, and snippets.

View dgtlmonk's full-sized avatar
💭
We first make our habits, and then our habits make us.

dgtlmonk dgtlmonk

💭
We first make our habits, and then our habits make us.
View GitHub Profile
@dgtlmonk
dgtlmonk / scribd2pdf.js
Created December 26, 2022 14:23 — forked from dbuezas/scribd2pdf.js
loads all jpegs and makes a pdf with them
load = async (url) => {
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= url;
return new Promise(resolve => {
script.addEventListener('load', resolve);
head.appendChild(script);
});
@dgtlmonk
dgtlmonk / react re-render
Created August 25, 2022 10:35
react re-render
React avoiding re-render
Children as Props
Moving state down
@dgtlmonk
dgtlmonk / expire check.js
Created April 30, 2022 09:47
check token expiration
import dateDiff from "date-fns/differenceInDays"
// JWT Token
dateExp = new Date(getToken().exp * 1000)
isTokenExpired = dateDiff(dateExp, Date.now()) < 1
@dgtlmonk
dgtlmonk / git-pushing-multiple.rst
Created April 18, 2021 09:30 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

function getBookingById(
ownerId: number,
bookingId: number,
fields: string[],
) {
return gql`
query getBookingById {
bookingsByOwnerIds(ownerIds: [${ownerId}], where: { id: ${bookingId} }) {
nodes {
${fields.join('\n')}
type Booking = {
id: number,
name: string
}
type BookingAndShit = {
selected?:boolean
}
interface Props<T> {
items: T[];
renderItem: (item: T) => React.ReactNode;
}
function List<T>(props: Props<T>) {
const { items, renderItem } = props;
const [state, setState] = React.useState<T[]>([]);
return (
export function Dashboard() {
const [data, setData] = React.useState([] as any);
const [editID, setEditID] = React.useState({} as any);
React.useEffect(() => {
setData(sampleProducts);
}, []);
const rowClick = (event: any) => {
setEditID(event.dataItem.ProductID);
Syncing a fork
The Setup
Before you can sync, you need to add a remote that points to the upstream repository. You may have done this when you originally forked.
Tip: Syncing your fork only updates your local copy of the repository; it does not update your repository on GitHub.
$ git remote -v
# List the current remotes
origin https://github.com/user/repo.git (fetch)
origin https://github.com/user/repo.git (push)
@dgtlmonk
dgtlmonk / master-javascript-interview.md
Created February 27, 2020 17:44 — forked from Geoff-Ford/master-javascript-interview.md
Eric Elliott's Master the JavaScript Interview Series