Skip to content

Instantly share code, notes, and snippets.

View sagartalla's full-sized avatar
:octocat:
Specialized in code repair

sagar talla sagartalla

:octocat:
Specialized in code repair
View GitHub Profile
@sagartalla
sagartalla / FunctionalComponent.jsx
Created May 22, 2020 15:37 — forked from agiveygives/FunctionalComponent.jsx
Testing React State with Hooks, Jest, and Enzyme
import React from 'react';
const TestComponent = () => {
const [count, setCount] = React.useState(0);
return (
<h3>{count}</h3>
<span>
<button id="count-up" type="button" onClick={() => setCount(count + 1)}>Count Up</button>
<button id="count-down" type="button" onClick={() => setCount(count - 1)}>Count Down</button>
@sagartalla
sagartalla / System Design.md
Created February 29, 2020 14:24 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@sagartalla
sagartalla / System Design.md
Created February 29, 2020 14:24 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?

How we incorporate next and cloudfront (2018-04-21)

Feel free to contact me at [email protected] or tweet at me @statisticsftw

This is a rough outline of how we utilize next.js and S3/Cloudfront. Hope it helps!

It assumes some knowledge of AWS.

Goals

import "./styles.css";
import axios from "axios";
import _ from "lodash";
import EN_KEYWORDS from "./en";
import AR_KEYWORDS from "./ar";
axios
.get(
"https://spreadsheets.google.com/feeds/list/157erdICVrm0UhD37trQDZuzS7JG4T5ejwoZS9zUilzo/od6/public/values?alt=json"
)
@sagartalla
sagartalla / NQ.js
Created July 12, 2019 15:11
N queens
/*
Eight Queens:Write an algorithm to print all ways of arranging eight queens on an 8x8 chess board
so that none of them share the same row, column, or diagonal. In this case, "diagonal" means all
diagonals, not just the two that bisect the board.
*/
var GRID_SIZE = 4;
function check(board, r1, c1) {
@sagartalla
sagartalla / index.html
Last active July 11, 2019 09:59
Coins: Given an infinite number of quarters (25 cents), dimes (1 O cents), nickels (5 cents), and pennies (1 cent), write code to calculate the number of ways of representing n cents.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
const debounce = (func, delay) => {
let clearTimer;
return function() {
const context = this;
const args = arguments;
clearTimeout(clearTimer);
clearTimer = setTimeout(() => func.apply(context, args), delay);
}
}
const throttle = (func, limit) => {
let lastFunc
let lastRan
return function() {
const context = this
const args = arguments
if (!lastRan) {
func.apply(context, args)
lastRan = Date.now()
} else {
@sagartalla
sagartalla / index.html
Created October 29, 2018 06:42
text color draw
<!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In -->
<svg id="surface" version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" x="0px" y="0px" width="387.4px" height="46.2px" viewBox="0 0 387.4 46.2" enable-background="new 0 0 387.4 46.2"
xml:space="preserve">
<defs>
</defs>
<g class="name">
<g class="letter">
<polyline style=" transform: translate(0px,-70px);" fill="none" stroke="#384B5F" stroke-width="7" points="0 66 9.6735081 106.441851 19.8420057 80 30.4937073 106.441851 40.0910027 66"></polyline>