Skip to content

Instantly share code, notes, and snippets.

View balvinder294's full-sized avatar
😎
Working Remotey

Balvinder Singh balvinder294

😎
Working Remotey
View GitHub Profile
import React from 'react';
const MyMemoComponent = React.memo(function MyComponent(props) {
return (
<div>
<p>Value: {props.value}</p>
</div>
);
});
@balvinder294
balvinder294 / pure-component.example.js
Created February 13, 2025 07:18
Pure Component Example
import React, { PureComponent } from 'react';
class MyPureComponent extends PureComponent {
render() {
return (
<div>
<p>Value: {this.props.value}</p>
</div>
);
}
import React, { useState } from 'react';
function ChildComponent(props) {
return (
<p>Message from parent: {props.message}</p>
);
}
function ParentComponent() {
const [parentMessage, setParentMessage] = useState("Initial message");
import React from 'react';
function Greeting(props) {
return (
<h1>Hello, {props.name}!</h1>
);
}
function ParentComponent() {
const name = "Alice"; // Example of data that could be dynamic
import React, { useState } from 'react';
function MyComponent() {
const [count, setCount] = useState(0);
const incrementCount = () => {
setCount(prevCount => prevCount + 1); // Use functional update for correct state updates
};
return (
@balvinder294
balvinder294 / index.html
Created January 24, 2023 16:56
A sample to use Browserify bundel containing Npm module in the browser | Tekraze.com
<script src="./example.js"></script>
<script>
async function someMethod() {
const res = window.Buffer.from('somestring');
}
</script>
Shared Hosting Dedicated Hosting
1. Shared Resources 1. Dedicated Resources
2. Cheap than Dedicated 2. Costlier than Dedicated
3. Mostly no root access 3. Root access available
4. Less control over resources and software 4. More control over resources and software
5. No custom software as they are shared by everyone 5. We can have custom software as there is no sharing
6. Good for small projects/testing sites and web apps 6. Good for large-scale and enterprise web apps and sites
7. Most storage is Hard Disk Drives 7. Storage is mostly SSD
8. No Customizable environment 8. Customizable environment
@balvinder294
balvinder294 / farming.txt
Created February 28, 2022 07:38
Farming votes
vote_from='michelangelo3' vote_to='dotwin1981' weight=25%
vote_from='michelangelo3' vote_to='ozelot47' weight=100%
vote_from='hornet-on-tour' vote_to='michelangelo3' weight=50%
vote_from='jeenger' vote_to='michelangelo3' weight=100%
vote_from='ozelot47' vote_to='michelangelo3' weight=25%
vote_from='michelangelo3' vote_to='elkezaksek' weight=100%
vote_from='dotwin1981' vote_to='michelangelo3' weight=100%
vote_from='jeenger' vote_to='michelangelo3' weight=25%
vote_from='michelangelo3' vote_to='elkezaksek' weight=25%
vote_from='michelangelo3' vote_to='ozelot47' weight=100%
@balvinder294
balvinder294 / main.py
Created January 18, 2022 19:04
Sample script to Create api from falcon and manipulate json from a url response
#author @tekraze
import falcon
import requests
class Hello:
def on_get(self, req, resp):
# we just send back a string here
resp.media = 'hello'
@balvinder294
balvinder294 / Dockerfile
Created January 18, 2022 17:18
Docker file to dockerize Falcon Python Api or app | https://tekraze.com
FROM python:3.11.0a3-alpine3.15
EXPOSE 8000
# Install gunicorn & falcon
RUN pip install gunicorn requests falcon --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org
# Add demo app
COPY ./app /app
WORKDIR /app