venego
Explore posts from serversTTCTheo's Typesafe Cult
•Created by venego on 4/1/2023 in #questions
How do I represent relationships in a sql database?
I don't want to duplicate the connection twice, so I though there would be a way to do this in sql.
I'm not good at sql, but I would assume that the logic of the query would be something like:
select col!='7mida' where userA='7mida' or userB='7mida' from connections;
Where "7mida" is the guy I'm trying to list his friends. So the table needs to be filtered twice in one query.
It's possible that I only filter once, using sql, and get something like so:
Then, using programming, I can let list only the ones that do not match the target's name. But I though first to check if something similar to the first option exists.
Please help!3 replies
TTCTheo's Typesafe Cult
•Created by venego on 3/3/2023 in #questions
How do I redraw DOM elements in a react component?
8 replies
TTCTheo's Typesafe Cult
•Created by venego on 3/1/2023 in #questions
how do I get an iso formated local date that matches my OS's one in js?
@corn flour you know...
30 replies
TTCTheo's Typesafe Cult
•Created by venego on 2/25/2023 in #questions
Is there a good sqlite client for js?
I'm really trying to cope with this one: https://www.npmjs.com/package/sqlite3
but seems like it has been designed to hate you.
9 replies
TTCTheo's Typesafe Cult
•Created by venego on 2/22/2023 in #questions
what's happening to tailwind's lsp client?
yesterday I left my code working, but today I don't know what is happening with tailwind,
I tried updating npm packages and everything.
this is the piece of code where I struggled to get tailwind to work: (simplified version)
when I inspect the dom in the browser, the classname is there but the actual class is not. seems like tailwind is running out of order??
note: other react+tailwind projects in my pc are working just fine.
how do I debug this?
100 replies
TTCTheo's Typesafe Cult
•Created by venego on 2/6/2023 in #questions
Is these animations a lot for a library like react?
I want to make an algorithm visualizer, like this one: https://www.toptal.com/developers/sorting-algorithms
I found this lib called
framer-motion
. I might be wrong but it seems that I need to re-render a lot to be able to build the project above.
I probably need charts because it's animating based on data. but I don't know a charting lib that is flexible enough.
Is there another way other than using pure js. or should I just learn another framework?1 replies
TTCTheo's Typesafe Cult
•Created by venego on 1/17/2023 in #questions
how do you change the parent branch in git?
Here is my current git graph:
I mistakenly though I was branching out of the last commit on main. but I instead branched out of
branchA
.
I don't wanna go through removing the branchA
changes from every single file on branchB
.
Is there a way to "rebase" the branchB - c1
on main - c2
without doing it the hard way?21 replies
TTCTheo's Typesafe Cult
•Created by venego on 1/8/2023 in #questions
can I have overlapping primary keys? (mysql)
I have this DB where I have two entities that has to be managed by a user.
The user can manage either one of the two entities or both.
So here is the structure:
the problem:
If a
user
has access to both A
and B
. he also can accidentally have access to one of them and the table would have partial duplication.
solutions in mind:
- I could only add privilege to only one of them entities at a time.
- I could have two privileges
tables. one for A
and another for B
I thought there should be some way to have an overlapped primary keys
or something similar.
my real question: Is there any other way to do this other than my simple solution?1 replies
TTCTheo's Typesafe Cult
•Created by venego on 12/23/2022 in #questions
media files do not show on my netlify site when I deploy my astro project.
I have this astro project working just fine on my local machine. when I do build and preview everything works as expected.
but when I deployed it on netlify all media files and favicon stopped working.
I have some fonts in the
src
directory and they work fine. but the media files in public
directory do not show up.
Is there a way to browse the file system on netlify or something similar?12 replies
TTCTheo's Typesafe Cult
•Created by venego on 12/19/2022 in #questions
I still have hmr.js when I do `pnpm build` in an Astro project???
how do I generate a production optimised build in Astro?
10 replies
TTCTheo's Typesafe Cult
•Created by venego on 12/16/2022 in #questions
is there an image lazy loading library for astro?
I found this cool library called
Blurr-Hash
with helps with lazy loading images in a really cool and efficient way.
but the thing is I also want to use this component from @astro/image
called Picture
where I can specify multiple versions/sizes of images.
and I don't know how to combine both, then I thought there must be some library for this that is specific to astro. unfortunately I found non.
How do I do this?4 replies
TTCTheo's Typesafe Cult
•Created by venego on 12/13/2022 in #questions
tailwind newly added spacing overrides the defaults
I just added this custom spacing to tailwind:
spacing: {main: '10%'}
and other spacings eg.py-4
stopped working.3 replies
TTCTheo's Typesafe Cult
•Created by venego on 12/1/2022 in #questions
adding typescript to a vite setup in progress
I have this project started with vite and after two moths of working with it, I finally realised that I really need typescript.
the problem is I can get vite to recognise typescript.
9 replies
TTCTheo's Typesafe Cult
•Created by venego on 11/28/2022 in #questions
html `img` tag considered as not same origin?
I have this API that is 100% allowing the client to access it, and now I'm trying make it serve images to the client.
so I setup everything and now I can visit the route (dedicated to static files serving) and browse to any file and get that file to show/download in my browser.
the only problem is when I use the
src
attribute of an html img
tag, I see this error in the browser: net::ERR_BLOCKED_BY_RESPONSE.NotSameOrigin 200
the url
in the src
is the same as the one I visit in the browser and the image loads successfully.52 replies
TTCTheo's Typesafe Cult
•Created by venego on 11/19/2022 in #questions
I can't inner join with a table twice
I have these two tables:
I need to inner join the two tables twice to get the owner and the author in one request.
the query I write is:
and I get this error:
sqlMessage: "Not unique table/alias: 'users'"
Is there a way to do it without having to query two times?
I suspect that the error is because the users table would output duplicate columns but how do I rename those columns for each inner join?9 replies
TTCTheo's Typesafe Cult
•Created by venego on 11/13/2022 in #questions
SSE - is it efficient to handle SSE this way?
I just learned about SSE and it seems each article is explaining SSE using an interval to write data to the stream.
isn't that going to cost more cpu and memory? especially that each request to the server is going to create another async function that is constantly checking for data change.
how can I trigger a stream-write whenever a database write has been made or something similar that is more precise?
how do I associate the session id with the actual user? can I include a cookie in the request?
14 replies
TTCTheo's Typesafe Cult
•Created by venego on 11/1/2022 in #questions
OAuth2+OIDC are very confusing
sorry for the very long-ass question, and thanks in advance.
not sure where to ask this. (OAuth2 implementation)
I just spent 6 hours watching videos and reading google-identity's docs on how to implement openIdConnect.
and I'm still very confused.
for example: (in the response_type)
If the value is code, launches a Basic authorization code flow, requiring a POST to the token endpoint to obtain the tokens. If the value is token id_token or id_token token, launches an Implicit flow, requiring the use of JavaScript at the redirect URI to retrieve tokens from the URI #fragment identifier.why would google send me a fragmented identifier? isn't the JWT token supposed to be sent to the server. is it secure that I get a url encoded hash that has the user's information in it... sent to the browser. I'm not sure about what I'm doing but here is how I'm implementing it: - in the browser, user clicks on
login with google
- user gets redirected to the back-end, the back-end generates the url encoded string for the consent.
- the consent(google's) redirects the user back to the font-end with the JWT token.
- I have to send that back to the back-end to do parse it and something with it (not sure about this yet)
here is the get request for the consent:
- why does google send the JWT as a hash? I would like to send it to my API instead of the browser
- why does it have to be JWT? while if I "misused the OAuth2" as an authentication method, I would get the user's data without having to deal with url decoding, base64 decoding.6 replies
TTCTheo's Typesafe Cult
•Created by venego on 10/24/2022 in #questions
Github is f***ed up.
hey I transferred all of my repos from Bitbucket to Github then realised that commits don't count(show up on my home page) because they don't have the author and email. then I found this bash trick to add email and author to all of my commits on a certain repo:
git filter-branch --commit-filter 'GIT_AUTHOR_NAME="username"; GIT_AUTHOR_EMAIL="email"; git commit-tree "$@";' HEAD
now Github counts the new commits but the old ones are not counted.
I'v also checked manually that all of the commits on that repo have email and author.
from this page I can say that they should be there on my home page:
https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-profile/managing-contribution-settings-on-your-profile/why-are-my-contributions-not-showing-up-on-my-profile
I've also found that I have not changed the committer name so this merging command helped me with that:
rebase -r [the initial commit] --exec 'git commit --amend --no-edit --reset-author'
but still... I waited 24h and still the board doesn't include the old commits, only the new ones.
it seems that github doesn't refresh the contributions board???
I recently discovered that the commits have been changed the problem is that the date also has been changed the date where I rebased... in all of the commits which made them appear as day of 30+ commits LOL.
I used this method to fix it:
- I use the interactive rebase git rebase i HEAD~[the end of the repo]
- then I change the commiter date for each one (not efficient though) GIT_COMMITTER_DATE="2022-10-01T19:00:00" git commit --amend --date="2022-10-01T19:00:00"
the new problem is that now on the contributions board I see 100 commits in one day WTF. in the repo I only have 39 commits. but it seems like whenever I rebase it appends to the history.
and the dates in my local git do not match the dates on github repo. and git says everything is up to date.
my hands are hurting, this is exhausting 🤬5 replies
TTCTheo's Typesafe Cult
•Created by venego on 10/23/2022 in #questions
how do you re-fetch with react-query?
it seems that they don't have such action:
useQuery(queryKey, queryFn?, {
cacheTime,
enabled,
networkMode,
initialData,
initialDataUpdatedAt,
isDataEqual,
keepPreviousData,
meta,
notifyOnChangeProps,
onError,
onSettled,
onSuccess,
placeholderData,
queryKeyHashFn,
refetchInterval,
refetchIntervalInBackground,
refetchOnMount,
refetchOnReconnect,
refetchOnWindowFocus,
retry,
retryOnMount,
retryDelay,
select,
staleTime,
structuralSharing,
suspense,
useErrorBoundary,
})
6 replies
TTCTheo's Typesafe Cult
•Created by venego on 10/21/2022 in #questions
what is the best way to redirect the user to login page in CSR?
I have this jamstack app and I want to redirect unauthenticated user to the login page, in case the session expired he still have the code in the browser to do certain actions. but the cookie is not there.
so in the server I only send a response with 200 status. that says
{redirect: true}
. and I act in the front based on that.
is this a good way to do it? or is there a more standard way?11 replies