Skip to content

Instantly share code, notes, and snippets.

View sunny-g's full-sized avatar

Sunny Gonnabathula sunny-g

View GitHub Profile
@wallyqs
wallyqs / Docker Compose + NATS example
Last active February 18, 2024 22:27
NATS Docker blog post/HTTP Server
FROM golang:1.6.2
COPY . /go
RUN go get github.com/nats-io/nats
RUN go build api-server.go
EXPOSE 8080
ENTRYPOINT ["/go/api-server"]
/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.
function queue(concurrency = 1) {
let running = 0
const taskQueue = []
const runTask = (task) => {
running++
task(() => {
running--
if (taskQueue.length > 0) {
runTask(taskQueue.shift())
const fetchContent = (url) =>
rx.Observable.create(observer =>
fetch(url)
.then(res => res.json())
.then(json => {
observer.onNext(json)
observer.onCompleted()
)
.catch(e => observer.onError())
)

System Design Cheatsheet

Step One: Framing The Problem a.k.a get the MVP

  • Identify the use cases that are in scope
  • Determine constraints based on scoped use cases

use case : the things your system needs to be do.

constraints : the things your system will have to consider to be able to do stuff

this.ycQuestions = [
"So what are you working on?",
"Have you raised funding?",
"What makes new users try you?",
"What competition do you fear most?",
"What’s the worst thing that has happened?",
"Will you reincorporate as a US company?",
"What’s an impressive thing you have done?",
"Where is the rocket science here?",
"Why did you pick this idea to work on?",
@grayrest
grayrest / index.jsx
Created April 12, 2016 18:12
Mobx Uptime Boxes
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import {observable, computed} from 'mobx';
import {observer} from 'mobx-react';
// import DevTools from 'mobx-react-devtools';
class Server {
@observable days = [];
@observable name = "";
@computed get upDays() {
@axic
axic / stringaskey.sol
Last active July 10, 2019 00:10
How to use string as a key in a mapping in Solidity aka. how to store short strings cheape
//
// In Solidity, a mapping is like a hashmap and works with `string` like this:
// mapping (string => uint) a;
//
// However it doesn't support accessors where string is a key:
// mapping (string => uint) public a;
//
// "Internal compiler error: Accessors for mapping with dynamically-sized keys not yet implemented."
//
// An accessor returns uint when called as `a(string)`.
@yinghaochan
yinghaochan / barChart.html
Last active February 29, 2016 21:10
Bar chart in react
<html>
<head>
<meta name="description" content="React Barchart animated">
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.5.1/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-with-addons.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></script>
<meta charset="utf-8">
@joshduck
joshduck / gist:0c35f70cdd3abf88770c
Created February 24, 2016 21:58
ReactPerf to Web Tracing Framework
const ReactPerf = require('ReactPerf');
const TRACE_DOM = false;
function reactPerfTrace(objName: string, fnName: string, func: any): any {
return function(component) {
let label;
if (objName === 'ReactCompositeComponent') {
var instName = this.getName() || 'Unknown';
label = fnName === 'mountComponent' || fnName === 'updateComponent' ? instName : `${instName}.${fnName}`;