├── .gitignore ├── All ├── APIS │ ├── Chatwoot.md │ ├── Daily.md │ ├── DuckDuckGo.md │ ├── Facebook.md │ ├── Google.md │ ├── Intercom.md │ ├── Mux.md │ ├── OpenAI.md │ ├── README.md │ ├── Reddit.md │ ├── Segment.md │ ├── Sendgrid.md │ ├── Sentry.md │ ├── Spotify.md │ ├── Stripe.md │ ├── Transloadit.md │ └── Zendesk.md ├── Bash │ ├── IO.md │ ├── Kill.md │ ├── Makefile.md │ ├── README.md │ ├── awk.md │ ├── bash_profile.md │ ├── cron.md │ ├── curl.md │ ├── diff.md │ ├── emacs.md │ ├── find.md │ ├── general.md │ ├── git.md │ ├── grep.md │ ├── installed │ │ ├── asdf.md │ │ ├── bit.md │ │ ├── ffmpeg.md │ │ ├── generact.md │ │ ├── graphite.md │ │ ├── ngrok.md │ │ ├── nvm.md │ │ ├── spell.md │ │ └── tmux.md │ ├── man.md │ ├── metadata.md │ ├── sed.md │ ├── sftp.md │ ├── ssh.md │ ├── vi.md │ ├── zip.md │ └── zsh.md ├── C++ │ └── ptrs.md ├── CS_Fundamentals │ ├── Authentication.md │ ├── Comparisons.md │ ├── Concurrency.md │ ├── Content_Security_Policy.md │ ├── Data_Structures.md │ ├── Editors.md │ ├── Email.md │ ├── Encryption.md │ ├── ErrorHandling.md │ ├── FeatureFlags.md │ ├── HTTP.md │ ├── IDs.md │ ├── LanguageTypes.md │ ├── Microservices.md │ ├── Optimization.md │ ├── Password_Hashing.md │ ├── RTMP.md │ ├── Real-Time.md │ ├── Sorting.md │ ├── StoringSecrets.md │ ├── Testing.md │ ├── WebRTC.md │ └── Webhook.md ├── Databases │ ├── README.md │ ├── SQL │ │ ├── README.md │ │ ├── aggregate.md │ │ ├── foreign_keys.md │ │ ├── joins.md │ │ ├── optimizations.md │ │ └── sqllite.md │ ├── advanced.md │ ├── design.md │ ├── firebase.md │ ├── hosts.md │ ├── libs.md │ ├── mongo.md │ ├── mongo_aggregation.md │ ├── opensearch.md │ ├── postgres.md │ ├── postgres_setup.md │ ├── redis.md │ └── tips.md ├── Dev_Apps │ ├── atom.md │ ├── iterm2.md │ ├── matlab.md │ ├── notion.md │ ├── retool.md │ ├── slack.md │ ├── tableplus.md │ ├── vimium.md │ ├── vscode.md │ ├── warp.md │ └── windows.md ├── Docker │ ├── README.md │ ├── basics.md │ ├── docker-compose.md │ ├── dockerfile.md │ ├── multistage.md │ └── swarm.md ├── Elixir │ ├── OTP.md │ ├── Phoenix │ │ ├── README.md │ │ ├── channels.md │ │ ├── controller_errors.md │ │ ├── controllers.md │ │ ├── db_ecto │ │ │ ├── README.md │ │ │ ├── changesets.md │ │ │ ├── generators.md │ │ │ ├── insert_update.md │ │ │ ├── many_to_many.md │ │ │ ├── migration.md │ │ │ ├── query.md │ │ │ ├── relations.md │ │ │ └── schema.md │ │ ├── deployment.md │ │ ├── file_structure.md │ │ ├── liveview.md │ │ ├── packages │ │ │ ├── corsplug.md │ │ │ ├── ratelimiting.md │ │ │ └── ueberauth.md │ │ ├── plug.md │ │ ├── presence.md │ │ ├── router.md │ │ ├── session.md │ │ ├── setup.md │ │ ├── testing.md │ │ ├── token.md │ │ ├── view_templates.md │ │ └── worker.md │ ├── README.md │ ├── collections │ │ ├── README.md │ │ ├── lists.md │ │ ├── map.md │ │ ├── set.md │ │ ├── strings.md │ │ ├── structs.md │ │ └── tuple.md │ ├── config.md │ ├── datetime.md │ ├── erlang.md │ ├── errors.md │ ├── file.md │ ├── functions.md │ ├── math.md │ ├── modules.md │ ├── packages │ │ ├── README.md │ │ ├── genstage.md │ │ ├── geolix.md │ │ ├── http │ │ │ ├── http.md │ │ │ ├── httpoison.md │ │ │ └── tesla.md │ │ ├── json.md │ │ ├── logger.md │ │ ├── nanoid.md │ │ ├── oban.md │ │ ├── redix.md │ │ ├── sentry.md │ │ ├── stripe.md │ │ ├── swoosh.md │ │ └── timex.md │ ├── process │ │ ├── README.md │ │ ├── agent.md │ │ ├── cron.md │ │ ├── genserver.md │ │ ├── registry.md │ │ ├── supervisor.md │ │ └── tasks.md │ ├── regex.md │ ├── setup.md │ ├── time.md │ └── uri.md ├── Elm.md ├── Go │ ├── .md │ ├── IO.md │ ├── JSON.md │ ├── README.md │ ├── assert.md │ ├── basics.md │ ├── collections │ │ ├── README.md │ │ ├── arrays.md │ │ ├── maps.md │ │ └── strings.md │ ├── control.md │ ├── dep.md │ ├── errors.md │ ├── files.md │ ├── func.md │ ├── goroutine.md │ ├── interfaces.md │ ├── math.md │ ├── request.md │ ├── server.md │ ├── structs.md │ ├── testing.md │ └── time.md ├── HTML │ ├── Forms.md │ ├── Fun.md │ ├── README.md │ ├── SEO.md │ ├── Templating │ │ ├── README.md │ │ ├── handlebars.md │ │ ├── jade&pug.md │ │ └── mustache.md │ ├── favicon.md │ ├── images.md │ ├── optimizations.md │ └── scripts.md ├── HeadlessCMS.md ├── Java.md ├── Php │ ├── AMP.md │ ├── Hack.md │ ├── README.md │ ├── requests.md │ └── setup.md ├── Python │ ├── 2.7v3.5.md │ ├── Django │ │ ├── README.md │ │ ├── db.md │ │ ├── models.md │ │ ├── packages │ │ │ └── django-environ.md │ │ ├── router.md │ │ ├── serializers.md │ │ ├── setup.md │ │ └── views.md │ ├── README.md │ ├── advanced.md │ ├── argparse.md │ ├── async.md │ ├── classes.md │ ├── collections │ │ ├── README.md │ │ ├── dict.md │ │ ├── fancyDicts.md │ │ ├── heap.md │ │ ├── list.md │ │ ├── set.md │ │ └── strings.md │ ├── crypto.md │ ├── environments.md │ ├── flask │ │ ├── README.md │ │ ├── blueprint.md │ │ ├── cli.md │ │ ├── config.md │ │ ├── deploying.md │ │ ├── flash.md │ │ ├── login.md │ │ ├── packages.md │ │ ├── packages │ │ │ ├── cors.md │ │ │ ├── mongoEngine.md │ │ │ └── socketio.md │ │ ├── postgres │ │ │ ├── README.md │ │ │ ├── migrate.md │ │ │ └── sqlalchemy.md │ │ ├── requests.md │ │ ├── response.md │ │ └── templating.md │ ├── importing.md │ ├── json.md │ ├── os&files.md │ ├── packages │ │ ├── aiohttp.md │ │ ├── aws │ │ │ ├── boto3.md │ │ │ └── dynamo.md │ │ ├── celery.md │ │ ├── cython.md │ │ ├── dotenv.md │ │ ├── excel.md │ │ ├── google.md │ │ ├── jupyter.md │ │ ├── langchain.md │ │ ├── matplotlib.md │ │ ├── numpy.md │ │ ├── pandas.md │ │ ├── passwords.md │ │ ├── pillow.md │ │ ├── praw.md │ │ ├── prisma.md │ │ ├── pydub.md │ │ ├── pymongo.md │ │ ├── pyppeteer.md │ │ ├── requests.md │ │ └── sqlalchemy.md │ ├── random.md │ ├── re.md │ ├── testing.md │ └── time.md ├── Scala │ ├── README.md │ ├── class.md │ ├── collections.md │ ├── exceptions.md │ ├── functions.md │ ├── futures.md │ ├── guice.md │ ├── loops.md │ ├── objects.md │ ├── options.md │ ├── packages.md │ ├── pattern&conditional.md │ ├── performance&style.md │ ├── sbt(running).md │ ├── strings.md │ ├── subtyping.md │ └── traits.md ├── Swift.md ├── solana.md └── solidity.md ├── CSS ├── Obscure.md ├── README.md ├── animations.md ├── background.md ├── border.md ├── colors.md ├── cursors.md ├── display.md ├── extras │ └── scss.md ├── fonts.md ├── gradients.md ├── lists.md ├── mediaQueries.md ├── object-fit.md ├── overflow.md ├── placement │ ├── README.md │ ├── box.md │ ├── columns.md │ ├── flexbox.md │ ├── grid.md │ ├── position.md │ └── tables.md ├── pseudoElements.md ├── selectors.md ├── tailwind │ ├── README.md │ ├── animations.md │ ├── general.md │ ├── media_queries.md │ ├── position.md │ ├── setup.md │ ├── size_spacing.md │ ├── text.md │ └── typography.md ├── transforms.md └── transitions.md ├── Deployment ├── AWS │ ├── ACM.md │ ├── Amplify.md │ ├── Cloudfront.md │ ├── Cloudwatch.md │ ├── Codebuild.md │ ├── Codedeploy.md │ ├── Codepipeline.md │ ├── Docker.md │ ├── EB.md │ ├── EC2 │ │ ├── README.md │ │ ├── Scripts.md │ │ ├── Types.md │ │ └── Usage.md │ ├── ELB.md │ ├── IAM.md │ ├── Lambda.md │ ├── README.md │ ├── SES.md │ ├── SQS.md │ ├── Storage │ │ ├── Aurora.md │ │ ├── Autoscaling.md │ │ ├── CustomEC2.md │ │ ├── DynamoDB.md │ │ ├── RDS.md │ │ ├── README.md │ │ └── S3.md │ ├── VPC.md │ ├── serverless.md │ └── zappa.md ├── Cloud GPUS │ ├── Beam.md │ ├── paperspace.md │ └── replicate.md ├── DNS.md ├── DigitalOcean.md ├── GCP │ ├── Compute.md │ ├── Network.md │ └── README.md ├── Github │ └── README.md ├── README.md ├── Render │ └── README.md ├── cloudflare.md ├── heroku.md ├── loadtesting.md ├── nginx.md ├── processManagement.md ├── redis.md ├── sockets.md ├── speed_opt.md ├── surge.md ├── task_queues.md ├── terraform.md └── vercel.md ├── JS ├── All │ ├── Angular │ │ ├── HTML.md │ │ ├── HTTP.md │ │ ├── bash.md │ │ ├── input.md │ │ ├── observable_Subject.md │ │ ├── router.md │ │ └── typescript.md │ ├── Chrome_Plugins │ │ ├── README.md │ │ ├── browser_action.md │ │ ├── config.md │ │ ├── content.md │ │ ├── context_menu.md │ │ ├── deploying.md │ │ ├── desktopcapture.md │ │ ├── events.md │ │ ├── identity.md │ │ ├── manifest.md │ │ ├── messages.md │ │ ├── notifications.md │ │ ├── popup.md │ │ ├── service_workers.md │ │ ├── setup.md │ │ ├── shortcuts.md │ │ ├── storage.md │ │ ├── tabs.md │ │ └── url_match.md │ ├── Electron │ │ ├── README.md │ │ ├── deeplinks.md │ │ ├── deploying.md │ │ ├── desktopCapturer.md │ │ ├── dialog.md │ │ ├── image.md │ │ ├── menu.md │ │ ├── messages.md │ │ ├── multiplatform.md │ │ ├── notarizing.md │ │ ├── notifications.md │ │ ├── packages │ │ │ ├── README.md │ │ │ ├── builder.md │ │ │ ├── electron-is-dev.md │ │ │ ├── electron-log.md │ │ │ ├── electron-store.md │ │ │ ├── forge.md │ │ │ └── sentry.md │ │ ├── renderer.md │ │ ├── screen.md │ │ ├── storage.md │ │ ├── tray.md │ │ └── window.md │ ├── Node │ │ ├── README.md │ │ ├── Routing.md │ │ ├── db │ │ │ ├── Mongoose.md │ │ │ ├── README.md │ │ │ ├── ioredis.md │ │ │ ├── knex.md │ │ │ ├── mongodb.md │ │ │ └── prisma.md │ │ ├── ejs.md │ │ ├── env.md │ │ ├── errors.md │ │ ├── files.md │ │ ├── forms.md │ │ ├── logging.md │ │ ├── middleware.md │ │ ├── packages │ │ │ ├── README.md │ │ │ ├── commander.md │ │ │ ├── config.md │ │ │ ├── crypto.md │ │ │ ├── dotenv.md │ │ │ ├── grant.md │ │ │ ├── helmet.md │ │ │ ├── http-errors.md │ │ │ ├── middleware.md │ │ │ ├── passport.md │ │ │ ├── puppeteer.md │ │ │ └── session.md │ │ ├── req.md │ │ ├── require.md │ │ ├── res.md │ │ └── setup.md │ └── bun.md ├── README.md ├── async&await.md ├── bundlers │ ├── parcel.md │ ├── vite.md │ └── webpack.md ├── closure.md ├── collections │ ├── JSON.md │ ├── README.md │ ├── arrays.md │ ├── blob.md │ ├── classes.md │ ├── map.md │ ├── objects.md │ ├── set.md │ └── string.md ├── dates.md ├── debugging.md ├── errors.md ├── es6.md ├── functions.md ├── importing.md ├── packages │ ├── README.md │ ├── ai.md │ ├── aws.md │ ├── babel.md │ ├── bcrypt.md │ ├── cheerio.md │ ├── concurrently.md │ ├── csv-parser.md │ ├── cypress.md │ ├── eslint.md │ ├── jest.md │ ├── lodash.md │ ├── matter.md │ ├── monaco-editor.md │ ├── node-sass.md │ ├── prettier.md │ ├── query-string.md │ ├── socket.md │ ├── supabase.md │ ├── trpc.md │ └── zod.md ├── promises.md ├── regex.md ├── requests.md ├── timeout.md ├── typescript │ ├── 3rd_party_types.md │ ├── README.md │ ├── classes.md │ ├── enum.md │ ├── generics.md │ ├── interface.md │ ├── migration.md │ ├── narrowing.md │ ├── packages │ │ └── trpc.md │ ├── types.md │ └── utility.md └── webJS │ ├── CORS.md │ ├── DOM.md │ ├── DOMShadow.md │ ├── README.md │ ├── audio.md │ ├── canvas.md │ ├── clipboard.md │ ├── cookies.md │ ├── events.md │ ├── iframe.md │ ├── intersectionobservers.md │ ├── keyboard.md │ ├── media.md │ ├── navigator.md │ ├── packages │ ├── Tabulator.md │ ├── bowser.md │ ├── boxicons.md │ ├── d3.md │ ├── mapbox.md │ ├── mousetrap.md │ └── videojs.md │ ├── scroll.md │ ├── simpleserve.md │ ├── storage.md │ └── worker.md ├── ML ├── .md ├── Deploy │ ├── Beam.md │ └── Paperspace.md ├── NLP │ ├── 1preprocessing.md │ ├── 2vectorizing.md │ ├── 3featureengineering.md │ ├── 4ml.md │ ├── 4ml2.md │ ├── Overview.md │ └── nltk.md ├── embedding.md ├── eval_llm.md ├── lowlevel │ ├── BuzzWordGuide.md │ ├── Regularization.md │ ├── datasets.md │ └── pytorch │ │ ├── README.md │ │ ├── datasets.md │ │ ├── gpu.md │ │ └── nn.md └── vector_store.md ├── README.md ├── React ├── All │ ├── Gatsby │ │ ├── README.md │ │ ├── cli.md │ │ ├── data.md │ │ ├── link.md │ │ ├── packages │ │ │ ├── mdx.md │ │ │ └── tailwindcss.md │ │ ├── pages.md │ │ ├── plugins.md │ │ ├── setup.md │ │ ├── style.md │ │ └── transformer.md │ ├── Prehooks │ │ ├── components.md │ │ ├── ref.md │ │ └── state&lifecycle.md │ └── React_Native │ │ ├── Expo │ │ ├── README.md │ │ ├── development_build.md │ │ ├── env.md │ │ └── setup.md │ │ ├── ListViews.md │ │ ├── README.md │ │ ├── SafeAreaView.md │ │ ├── defaultComponents.md │ │ ├── fetch.md │ │ ├── gestures.md │ │ ├── navigation.md │ │ ├── notification.md │ │ ├── orientation.md │ │ ├── packages │ │ ├── reanimated.md │ │ └── screenshot.md │ │ ├── style.md │ │ └── width_height.md ├── Next │ ├── Image.md │ ├── PreAppRouter │ │ ├── SSR.md │ │ ├── api.md │ │ ├── head.md │ │ ├── layouts.md │ │ └── routing.md │ ├── README.md │ ├── api.md │ ├── app_router.md │ ├── assets.md │ ├── config.md │ ├── css.md │ ├── deploying.md │ ├── layouts.md │ ├── markdown.md │ ├── metadata.md │ ├── packages │ │ ├── contentlayer.md │ │ ├── mdx.md │ │ └── t3-env.md │ ├── routing.md │ ├── server_actions.md │ └── setup.md ├── README.md ├── assets.md ├── children.md ├── context.md ├── data_loading │ ├── README.md │ └── react-query.md ├── deployment.md ├── effect.md ├── errors.md ├── events.md ├── forms.md ├── hooks.md ├── jsx.md ├── lists.md ├── optimization.md ├── packages │ ├── SWR.md │ ├── classnames.md │ ├── color.md │ ├── datepicker.md │ ├── draggable.md │ ├── emotion.md │ ├── feather.md │ ├── fluxible.md │ ├── general.md │ ├── google.md │ ├── intersection-observer.md │ ├── lazyload.md │ ├── load-script.md │ ├── proptypes.md │ ├── react-router.md │ ├── recharts.md │ ├── select.md │ ├── shadcn.md │ ├── slate.md │ ├── table.md │ ├── tanstack-router.md │ ├── telephone.md │ ├── three-fiber.md │ ├── toastify.md │ ├── tooltip.md │ ├── videojs.md │ ├── waypoint.md │ ├── window.md │ └── xstate.md ├── render.md ├── server_components.md ├── setup.md ├── state.md ├── state_management │ ├── README.md │ ├── jotai.md │ ├── mobx.md │ ├── redux │ │ ├── README.md │ │ ├── immer.md │ │ ├── middleware.md │ │ ├── react-redux.md │ │ ├── redux.md │ │ ├── redux_toolkit.md │ │ ├── selectors.md │ │ ├── setup.md │ │ └── thunk.md │ └── zustand.md ├── style.md └── suspense.md ├── Rust ├── Error.md ├── Importing.md ├── Ownership.md └── README.md ├── chrome.md ├── debugging.md ├── google.md ├── graphQL.md ├── mac.md ├── markdown.md ├── regex.md ├── techtotry.md └── typora.md /.gitignore: -------------------------------------------------------------------------------- 1 | Ecstatic/ 2 | .DS_Store 3 | Coursera/ 4 | Facebook/ 5 | Latent/ 6 | latent.md 7 | *~* 8 | -------------------------------------------------------------------------------- /All/APIS/DuckDuckGo.md: -------------------------------------------------------------------------------- 1 | # DuckDuckGo 2 | 3 | Great image search 4 | 5 | ## [Python](https://pypi.org/project/duckduckgo-images-api/) 6 | 7 | ```python 8 | from duckduckgo_images_api import search 9 | results = search("nike") 10 | [result["image"] for result in results["results"]] 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /All/APIS/README.md: -------------------------------------------------------------------------------- 1 | # APIS 2 | 3 | #### Designing An API 4 | 5 | How to ensure your open api is secures 6 | 7 | https://softwareengineering.stackexchange.com/questions/219028/how-to-safeguard-a-rest-api-for-only-trusted-mobile-applications 8 | 9 | ## Oauth 10 | 11 | Implicit Flow just has one less step so easier, but less secure or something. Doing a get request with access_token lets anyone who can see your history or url gets have it which is less secure than the regular oauth post request. -------------------------------------------------------------------------------- /All/APIS/Stripe.md: -------------------------------------------------------------------------------- 1 | # Stripe 2 | 3 | ## Elixir 4 | 5 | ```elixir 6 | {:stripity_stripe, "~> 2.0"}, 7 | ``` 8 | 9 | https://github.com/code-corps/stripity_stripe 10 | 11 | Stripe.Customer.retrieve("cus_jkldfsajklafjs") -------------------------------------------------------------------------------- /All/Bash/Kill.md: -------------------------------------------------------------------------------- 1 | ## Kills 2 | Ctrl+C Kills SIGINT 3 | Ctrl+Z Suspends with SIGSTOP 4 | Ctrl+/ Is merciless 5 | `ps` 6 | `kill -9 [pid]` 7 | 8 | `lsof -i :3000` to find the process running on port 3000 9 | 10 | - basically looks at lists open files 11 | 12 | -------------------------------------------------------------------------------- /All/Bash/Makefile.md: -------------------------------------------------------------------------------- 1 | # Makefile 2 | 3 | Makefile name 4 | 5 | ```makefile 6 | CC=gcc 7 | CFLAGS=-I. 8 | DEPS = hellomake.h 9 | 10 | %.o: %.c $(DEPS) 11 | $(CC) -c -o $@ $< $(CFLAGS) 12 | 13 | hellomake: hellomake.o hellofunc.o 14 | $(CC) -o hellomake hellomake.o hellofunc.o 15 | ``` 16 | 17 | ## Differences From Bash 18 | 19 | - It seems \$PWD works instead of \$(pwd) within a command 20 | - To do command after a cd, use semicolon 21 | 22 | ```makefile 23 | cd ./client; yarn build; 24 | ``` 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /All/Bash/diff.md: -------------------------------------------------------------------------------- 1 | # Diff 2 | 3 | ## Find differences between two folders 4 | 5 | ```bash 6 | diff -bur react_phoenix Phoenix-React-Base 7 | diff -bur --brief react_phoenix Phoenix-React-Base #show summary 8 | diff -bur --brief react_phoenix Phoenix-React-Base -x deps #ignore deps folder 9 | ``` 10 | 11 | -------------------------------------------------------------------------------- /All/Bash/emacs.md: -------------------------------------------------------------------------------- 1 | # Emacs 2 | 3 | If emacs is opening in a window, run `emacs -nw` 4 | 5 | M means Alt 6 | 7 | | Cmd | Effect | 8 | | ----- | ------------------------ | 9 | | C - v | Next Page | 10 | | C - p | Previous Line | 11 | | C - a | Start of Line | 12 | | C - e | End of Line | 13 | | C-x u | Undo | 14 | | C - n | Next Line | 15 | | C - k | Kill(delete? copy?) line | 16 | | | | 17 | | | | 18 | 19 | ## Selecting Text 20 | 21 | Ctrl - Space sets a mark and then move cursor and it will select all the text from the mark to the cursor with wrapping 22 | 23 | | Cmd | Effect | 24 | | ---- | ------ | 25 | | C-w | Cut | 26 | | M-w | Copy | 27 | | C-y | Paste | 28 | 29 | -------------------------------------------------------------------------------- /All/Bash/find.md: -------------------------------------------------------------------------------- 1 | # Find 2 | 3 | recursively descends the directory tree for each path listed, evaluating an expression 4 | 5 | *wont follow soft links* 6 | 7 | ### Find file by name 8 | 9 | ```bash 10 | find . -iname [word] 11 | find . -iname local # => ./Projects/local 12 | ``` 13 | 14 | #### Find some string in all files in cur dir 15 | 16 | ```bash 17 | find . -type f -print0 | xargs -0 18 | # OR 19 | grep "some string" 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /All/Bash/general.md: -------------------------------------------------------------------------------- 1 | ## Understand Machine 2 | 3 | `top` see mem usage 4 | 5 | `du -sh` to see size of dir 6 | 7 | `du -h --max-depth=1 | sort -hr` to see size of dirs/files in folder 8 | 9 | `tail ` get end of file, `tail -f` to open buffer and show end of file updating 10 | 11 | `head` get start of file 12 | 13 | ## Pbcopy 14 | 15 | `pbcopy < atom.sh` 16 | 17 | ## Word Count(wc) 18 | 19 | `wc -l [filename]` 20 | 21 | #### Find number of lines in a directory 22 | 23 | `find . -name '*' | xargs cat | wc -l` 24 | 25 | ## XARGS 26 | 27 | `cat [filename] | xargs wc -l` => `wc -l [filename]` 28 | 29 | `xargs [utility] [utility args]` 30 | 31 | reads from the standard input 32 | and executes utility 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /All/Bash/installed/generact.md: -------------------------------------------------------------------------------- 1 | # Generact 2 | 3 | Duplicate react components 4 | 5 | ```bash 6 | generact 7 | ``` 8 | 9 | That is it the UI will take it from there -------------------------------------------------------------------------------- /All/Bash/installed/ngrok.md: -------------------------------------------------------------------------------- 1 | # Run a Server From LocalHost to the World 2 | 3 | `ngrok http [THE PORT YOU WANT]` 4 | 5 | Then just go to that url and its exposed to the world ez 6 | 7 | #### Inspect Incoming Request 8 | 9 | http://localhost:4040/inspect/http ez -------------------------------------------------------------------------------- /All/Bash/installed/nvm.md: -------------------------------------------------------------------------------- 1 | # Node Version Manager 2 | 3 | **Use asdf instead cuz its more general** 4 | 5 | ### Setup 6 | 7 | ``` 8 | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash 9 | ``` 10 | 11 | ### Install Nodes 12 | 13 | ``` 14 | nvm install --lts 15 | nvm --help 16 | ``` 17 | 18 | help gives most of what you need -------------------------------------------------------------------------------- /All/Bash/installed/spell.md: -------------------------------------------------------------------------------- 1 | # Spell 2 | 3 | Run code on GPUS like a god 4 | 5 | ## Setup 6 | 7 | ```bash 8 | spell login 9 | spell whoami 10 | ``` 11 | 12 | ## Usage 13 | 14 | ```bash 15 | # default CPU 16 | spell run "python example.py" 17 | 18 | # Nvidia's Tesla K80 19 | spell run -t K80 "python example.py" 20 | 21 | # Nvidia's Tesla V100 multi-GPU option 22 | spell run -t V100x4 "python multi-example.py" 23 | ``` 24 | 25 | ## Resources 26 | 27 | Store data in resources 28 | 29 | ```bash 30 | spell upload simpleNN/data/ 31 | spell ls 32 | ``` 33 | 34 | ## Workspace 35 | 36 | Create a workspace in the GUI, upload a jupyter file, and goooooo ez. Easily use resources. -------------------------------------------------------------------------------- /All/Bash/man.md: -------------------------------------------------------------------------------- 1 | # Man 2 | 3 | `man ls` will open manual on ls with all options 4 | 5 | ### Searching 6 | 7 | `/` - open find 8 | 9 | `n` - go to next find -------------------------------------------------------------------------------- /All/Bash/metadata.md: -------------------------------------------------------------------------------- 1 | # Editing File Metadata 2 | 3 | Metadata is like where a file was downloaded from and such: 4 | 5 | ## Editing 6 | 7 | ``` 8 | xattr -l file.flv 9 | com.apple.metadata:kMDItemWhereFroms: 10 | 00000000 62 70 6C 69 73 74 30 30 A1 01 5F 11 01 7F 68 74 |bplist00.._...ht| 11 | 00000010 74 70 3A 2F 2F 73 31 73 64 6C 6F 64 30 35 33 2E |tp://s1sdlod053.| 12 | 00000020 62 63 73 74 2E 63 64 6E 2E 73 31 73 2E 79 69 6D |bcst.cdn.s1s.yim| 13 | 00000030 67 2E 63 6F 6D 2F 2F 73 31 73 6E 66 73 30 36 72 |g.com//s1snfs06r| 14 | 00000040 30 35 2F 30 30 35 2F 76 69 64 65 6F 73 65 61 72 |05/005/videosear| 15 | 00000050 63 68 2F 39 30 35 32 32 35 37 37 2E 66 6C 76 3F |ch/90522577.flv?| 16 | 00000060 53 74 72 65 61 6D 49 44 3D 39 30 35 32 32 35 37 |StreamID=9052257| 17 | ... 18 | 19 | xattr -w "com.apple.metadata:kMDItemWhereFroms" 20 | "http://topdocumentaryfilms.com/journey-edge-universe/" file.flv 21 | ``` -------------------------------------------------------------------------------- /All/Bash/sed.md: -------------------------------------------------------------------------------- 1 | # Sed 2 | 3 | Stream editor to do bash text manipulation 4 | 5 | ### String Substituting 6 | 7 | First one hit 8 | 9 | ```bash 10 | sed 's/hello/world/' input.txt > output.txt 11 | ``` 12 | 13 | Translate all 14 | 15 | ```bash 16 | echo "hello hello my world world" | sed 's/hello/world/g' 17 | ``` 18 | 19 | -------------------------------------------------------------------------------- /All/Bash/sftp.md: -------------------------------------------------------------------------------- 1 | # Secure File Transfer Protocol 2 | 3 | ```bash 4 | sftp -i "~/Desktop/pem/Slingshow-1.pem" ec2-user@ec2-54-229-73-137.us-west-1.compute.amazonaws.com 5 | ``` 6 | 7 | Opens a ssh shell on the remote host with limited functionality 8 | 9 | Use regular bash cmds to move around(`ls`, `cd`) 10 | 11 | `help` in sftp shows you the list of acceptable commands(limited bash) 12 | 13 | ### Put in EC2/remote server 14 | 15 | ```bash 16 | put [local_filename] 17 | put -r [local_directory] 18 | ``` 19 | 20 | #### Get from remote 21 | 22 | ```bash 23 | get remoteFile localFile 24 | ``` 25 | 26 | ## Local interaction 27 | 28 | preface commands with l to run them locally i.e 29 | 30 | `lpwd` => local directory 31 | 32 | `lcd`, `lls` etc 33 | 34 | node test_attendee join --host eta-staging.onrender.com -m -h -n 4 HkQm-QyN 35 | -------------------------------------------------------------------------------- /All/Bash/ssh.md: -------------------------------------------------------------------------------- 1 | # SSH 2 | 3 | Secure shell, remote computer access 4 | 5 | ssh [username]@[public-DNS] 6 | 7 | `exit` to close connection 8 | 9 | ## Generate new ssh key 10 | 11 | ```bash 12 | ssh-keygen 13 | 14 | cat ~/.ssh/id_rsa.pub #to see public key 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /All/Bash/vi.md: -------------------------------------------------------------------------------- 1 | # Vi 2 | 3 | ESC => enter edit mode 4 | 5 | | :wq | Save and quit | 6 | | ------ | -------------- | 7 | | dd | delete line | 8 | | dd2 | delete 2 lines | 9 | | ctrl-f | Forward page | 10 | | ctrl-b | Back page | 11 | | | | 12 | | | | 13 | | | | 14 | | | | 15 | | | | 16 | 17 | i => enter insert mode to type 18 | 19 | -------------------------------------------------------------------------------- /All/C++/ptrs.md: -------------------------------------------------------------------------------- 1 | # Ptrs 2 | 3 | ### Advanced 4 | 5 | Smart ptrs are meant to solve many ptr problems like leaky mem and dangling ptrs by introducing the concept of ownership 6 | 7 | Unique_ptrs are ptrs that can't be copied and delete the underlying mem when the ptr itself is deleted 8 | 9 | Shared ptrs keep track of how many ptrs have access to the underlying object and delete the underlying object when there are no more references 10 | 11 | -------------------------------------------------------------------------------- /All/CS_Fundamentals/Concurrency.md: -------------------------------------------------------------------------------- 1 | ## Semaphore 2 | 3 | tracks only *how many* resources are free; not *which* of the resources are free.To select can use more semaphores or something else 4 | 5 | a **semaphore** is var to control access to multithreaded apps 6 | 7 | Can have int **counting semaphores** or **binary semaphores** 8 | 9 | used to implement locks -------------------------------------------------------------------------------- /All/CS_Fundamentals/Email.md: -------------------------------------------------------------------------------- 1 | # Email 2 | 3 | If email deliverability low, checkout 4 | 5 | [Email Tester]([http://www.mail-tester.com/) 6 | 7 | https://sendgrid.com/blog/how-to-authenticate-your-email-in-5-steps/ 8 | 9 | https://dmarcly.com/blog/how-to-add-spf-record-in-cloudflare-cloudflare-spf-setup-guide 10 | 11 | https://support.google.com/mail/answer/180707?authuser=1 -------------------------------------------------------------------------------- /All/CS_Fundamentals/Encryption.md: -------------------------------------------------------------------------------- 1 | # Encryption 2 | 3 | Good [security resource](https://cheatsheetseries.owasp.org/) 4 | 5 | ## Password 6 | 7 | Don't use MD5, SHA1, SHA2, SHA3, etc 8 | 9 | Instead use something that takes longer like Blowfish with salts 10 | 11 | ### Password Reset 12 | 13 | Tokens should: 14 | 15 | - Expire 16 | - Be unpredicatable 17 | - Encrypted like credientials b/c they can basically be used a password 18 | - Security questions? 19 | 20 | -------------------------------------------------------------------------------- /All/CS_Fundamentals/ErrorHandling.md: -------------------------------------------------------------------------------- 1 | # Errors 2 | 3 | Operational errors must be handled gracefully like: 4 | 5 | - failed to connect to server 6 | - failed to resolve hostname 7 | - invalid user input 8 | - request timeout 9 | - server returned a 500 response 10 | - socket hang-up 11 | - system is out of memory -------------------------------------------------------------------------------- /All/CS_Fundamentals/FeatureFlags.md: -------------------------------------------------------------------------------- 1 | # Feature Flags 2 | 3 | Easily enable or disable features for experimentation or slow rollouts 4 | 5 | - https://www.growthbook.io/) 6 | 7 | https://software.rajivprab.com/2019/12/19/when-feature-flags-do-and-dont-make-sense/ 8 | 9 | ### Simplest 10 | 11 | Store in a db 12 | 13 | name | is_active 14 | 15 | Then write api to fetch is_active for that name before enabling. Or just fetch all feature flags on load and store in cookie or localStorage so persists. Hash user_id and name into % so stable percentage difference. Add custom flagging for user field and add in flags check. 16 | 17 | #### Why feature flag provider? 18 | 19 | A feature flag provider has a seperate db, audit log, user interface, code to automatically keep clientside flags updated(worker with socket), **enable for selective users**, 20 | 21 | Providers: 22 | 23 | - LaunchDarkly 24 | - Posthog 25 | - [Growthbook]( -------------------------------------------------------------------------------- /All/CS_Fundamentals/Microservices.md: -------------------------------------------------------------------------------- 1 | # Microservices 2 | 3 | - increases developer productivity by allowing independent deployment for many people when people step on each others toes 4 | - decreases developer productivity for changes that require many service changes -------------------------------------------------------------------------------- /All/CS_Fundamentals/Optimization.md: -------------------------------------------------------------------------------- 1 | # Optimization 2 | 3 | ## Latency 4 | 5 | - L1 cache reference 0.5 ns 6 | - Branch mispredict 5 ns 7 | - L2 cache reference 7 ns 8 | - Mutex lock/unlock 100 ns 9 | - Main memory reference 100 ns 10 | - Compress 1K bytes with Zippy 10,000 ns 11 | - Send 2K bytes over 1 Gbps network 20,000 ns 12 | - Read 1 MB sequentially from memory 250,000 ns 13 | - Round trip within same datacenter 500,000 ns 14 | - Disk seek 10,000,000 ns 15 | - Read 1 MB sequentially from network 10,000,000 ns 16 | - Read 1 MB sequentially from disk 30,000,000 ns 17 | - Send packet CA->Netherlands->CA 150,000,000 ns 18 | 19 | ## Server 20 | 21 | https://code.tubitv.com/how-we-discovered-a-7-year-old-performance-issue-in-elixir-99080bdce9a1 -------------------------------------------------------------------------------- /All/CS_Fundamentals/Password_Hashing.md: -------------------------------------------------------------------------------- 1 | # Password Hashing 2 | 3 | Recommendation: Argon2, won 2014-2016 password hashing contest 4 | 5 | https://guptadeepak.com/comparative-analysis-of-password-hashing-algorithms-argon2-bcrypt-scrypt-and-pbkdf2/ 6 | 7 | 1. **Argon2**: Likely to see increased adoption as the new standard for password hashing. Its flexibility and security make it well-positioned for future cryptographic needs. 8 | 2. **bcrypt**: Will continue to be widely used due to its established presence and simplicity. However, it may gradually be replaced by Argon2 in high-security applications. 9 | 3. **scrypt**: Will remain relevant, especially in cryptocurrency and other memory-hard applications. However, it may lose ground to Argon2 in general use cases. 10 | 4. **PBKDF2**: Due to its widespread implementation and FIPS compliance, PBKDF2 will continue to be used, but it's likely to be phased out in favor of more secure alternatives for password hashing. -------------------------------------------------------------------------------- /All/CS_Fundamentals/Real-Time.md: -------------------------------------------------------------------------------- 1 | # Real-Time 2 | 3 | How do you do stuff like realtime updates, push changes from server to clients? 4 | 5 | ## Websockets 6 | 7 | [Sockets.io](https://socket.io/) 8 | 9 | - Create a sustained connection that both sides listen to 10 | - Remove work of constantly doing a handshake, creating a connection, and sending headers 11 | 12 | #### Polling 13 | 14 | Client requests updates from server on schedule 15 | 16 | #### Long polling / Server-Sent Events 17 | 18 | The client asks for info and the server keeps the connection open until a response, uses the EventSource API 19 | 20 | ## Kafka 21 | 22 | Heavy duty producer consumer relationship 23 | 24 | All these producers publish to kafka to their own or a common stream, and all these consumers can subscribe to the data streams 25 | 26 | -------------------------------------------------------------------------------- /All/CS_Fundamentals/Sorting.md: -------------------------------------------------------------------------------- 1 | # Sorting 2 | 3 | - Quick Sort: O(nlogn) in practice but O(n²) worst-case, sort around pivot 4 | - Merge Sort, Heap Sort: Consistent O(n log n) 5 | - Bubble Sort, Insertion Sort, Selection Sort: Simple O(n^2) 6 | - Counting Sort, Radix Sort**: Non-comparison sorts, efficient for specific use cases.** 7 | - Tim Sort: Highly optimized for real-world data and widely used in standard libraries including JS and Python, basically combined Merge Sort and Insertion Sort -------------------------------------------------------------------------------- /All/CS_Fundamentals/StoringSecrets.md: -------------------------------------------------------------------------------- 1 | # Storing Secrets 2 | 3 | There are many heavy weight solutions that you should look into if you become a team with many credentials including blackbox, https://www.chef.io/, https://square.github.io/keywhiz/. Can also have files encrypted on github with things like git-crypt 4 | 5 | ## Simple Solutions 6 | 7 | ### Environment Variables 8 | 9 | - easy load from file 10 | - often use env variables for other things too so good to set up 11 | 12 | Cons: 13 | 14 | - According to https://news.ycombinator.com/item?id=9952911, its possible that environment variables are shown in debug output when a server crashes potentially comprising the system 15 | - Can't revoke secrets.json or manage like an expert 16 | 17 | ### Seperate Secrets.json 18 | 19 | - Easiest 20 | 21 | -------------------------------------------------------------------------------- /All/CS_Fundamentals/Testing.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | Diminishing returns for code coverage given time 4 | 5 | Good Tests: 6 | 7 | - run fast 8 | - doesn't break often 9 | - easy to understand 10 | - catches bugs 11 | - good coverage to effort ratio 12 | 13 | ### Test Strategy 14 | 15 | Need Iteration to find good test strategy 16 | 17 | Mocking too much reduces test quality 18 | 19 | Good ideas: 20 | 21 | - Writing test setup utilities functions 22 | - Categorize types of tests and make templates -------------------------------------------------------------------------------- /All/CS_Fundamentals/WebRTC.md: -------------------------------------------------------------------------------- 1 | # WebRTC 2 | 3 | Google supported standard for easy p2p communication that can then scale to use an intermediate server for > 4 4 | 5 | Handles everything from stabilization, codecs, etc for ez use and multi platform including many browsers and matching native performance 6 | 7 | Beyond about 3/4, probably need a server to communicate because all the devices will connect and send data to every other device 8 | 9 | Need signal server to let the peers communicate session data to begin connection 10 | 11 | Need a hosted STUN / TURN server to handle fallback when because of NAT or other, the p2p connection fails 12 | 13 | ##### Interface 14 | 15 | MediaStreams 16 | 17 | P2P Connections 18 | 19 | ### Debugging 20 | 21 | chrome://media-internals 22 | 23 | -------------------------------------------------------------------------------- /All/CS_Fundamentals/Webhook.md: -------------------------------------------------------------------------------- 1 | # Webhook 2 | 3 | Instead of pulling the data like an API, a webhook is when the provider pushes the data to you by sending a post request. 4 | 5 | Good for: 6 | 7 | - When events can happen at anytime, like payment authorization takes days 8 | 9 | Authentication 10 | 11 | - Stripe signs requests 12 | - Pass secrets or tokens like GitHub 13 | - Api Key stored by provider 14 | 15 | -------------------------------------------------------------------------------- /All/Databases/SQL/aggregate.md: -------------------------------------------------------------------------------- 1 | # Aggregate 2 | 3 | When you use GROUP_BY, you can only select aggregates or columsn in the GROUP_BY 4 | 5 | #### Count 6 | 7 | - `COUNT(*)` /`COUNT(1)`counts all rows 8 | - `COUNT(column)` counts non-NULLs only 9 | 10 | ```sql 11 | SELECT COUNT(*) FROM orders GROUP BY ds; 12 | ``` 13 | 14 | #### Max 15 | 16 | Even works for strings where later in the alphabet is more 17 | 18 | #### Min 19 | 20 | Even works for strings where later in the alphabet is more -------------------------------------------------------------------------------- /All/Databases/SQL/joins.md: -------------------------------------------------------------------------------- 1 | # JOINS 2 | 3 | `:inner_join`, `:left_join`, `:right_join`, `:cross_join`, `:full_join`, `:inner_lateral_join` or `:left_lateral_join`. `:join` is equivalent to `:inner_join`(match both returned) 4 | 5 |     6 | 7 | -------------------------------------------------------------------------------- /All/Databases/SQL/optimizations.md: -------------------------------------------------------------------------------- 1 | # Optimizations 2 | 3 | ### N+1 Queries 4 | 5 | ```php 6 | $cats = load_cats(); 7 | foreach ($cats as $cat) { 8 | $cats_hats = load_hats_for_cat($cat); 9 | // ... 10 | } 11 | ``` 12 | 13 | ``` 14 | SELECT * FROM cat WHERE ... 15 | SELECT * FROM hat WHERE catID = 1 16 | SELECT * FROM hat WHERE catID = 2 17 | SELECT * FROM hat WHERE catID = 3 18 | SELECT * FROM hat WHERE catID = 4 19 | SELECT * FROM hat WHERE catID = 5 20 | ``` 21 | 22 | Instead do 23 | 24 | ```php 25 | $cats = load_cats(); 26 | $hats = load_all_hats_for_these_cats($cats); 27 | foreach ($cats as $cat) { 28 | $cats_hats = $hats[$cat->getID()]; 29 | } 30 | ``` 31 | 32 | ``` 33 | SELECT * FROM cat WHERE ... 34 | SELECT * FROM hat WHERE catID IN (1, 2, 3, 4, 5, ...) 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /All/Databases/SQL/sqllite.md: -------------------------------------------------------------------------------- 1 | # SQL Lite 2 | 3 | SQL DB stored in a local file and capable of being used in many different device types 4 | 5 | ``` 6 | sqlite dbfile.db 7 | .tables 8 | select * from cards limit 1; 9 | ``` 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /All/Databases/advanced.md: -------------------------------------------------------------------------------- 1 | # Advanced (Postgres?) 2 | 3 | ### Transactions 4 | 5 | Transactions group db commands to be atomic, all or nothing, and permanently recorded to disk(not dirty/in memory) 6 | 7 | Useful for something like bank transfers where you want to ensure an amount is deducted and added or nothing 8 | 9 | ```sql 10 | BEGIN; 11 | UPDATE accounts SET balance = balance - 100.00 12 | WHERE name = 'Alice'; 13 | -- etc etc 14 | COMMIT; 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /All/Databases/hosts.md: -------------------------------------------------------------------------------- 1 | # Hosts 2 | 3 | ## Mongodb 4 | 5 | - DocumentDB AWS 6 | + Unconfirmed cant use Mongoose 7 | + Steep $200/month start(need I say more) 8 | - Mongodb Atlas 9 | - Free tier of 512 MB -------------------------------------------------------------------------------- /All/Databases/libs.md: -------------------------------------------------------------------------------- 1 | # Code Abstractions 2 | 3 | ## Database Driver 4 | 5 | - raw SQL strings delievered to database with async? Rest 6 | - connection pooling 7 | 8 | ## Query Builder 9 | 10 | - programmatically generate dynamic queries in a much more convenient way 11 | - generate queries for a few different SQL dialects 12 | - **sweetspot of SQL** because clear connection to general SQL, yet dealing with fts instead of strings 13 | 14 | ## ORM 15 | 16 | - map a record in a relational database to an object 17 | - Do object validation on NoSQL and create generated properties and class fields 18 | - Learn a ORM specific interface rather than SQL 19 | - Must update code when you update database slowing down iterations early 20 | - Cant do everything in an ORM meaning you dip into SQL or do some inefficient code 21 | - **sweetspot of NoSQL**, adds needed things like object validation -------------------------------------------------------------------------------- /All/Databases/redis.md: -------------------------------------------------------------------------------- 1 | # [Redis](https://redis.io/docs/install/install-redis/install-redis-on-mac-os/) 2 | 3 | ```bash 4 | brew install redis 5 | ``` 6 | 7 | ## Usage 8 | 9 | ``` 10 | redis-cli 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /All/Databases/tips.md: -------------------------------------------------------------------------------- 1 | # Tips 2 | 3 | - If the user will submit it via a form, it is best to allow the ids to be client generated so the ids on the client and the server can be the same after a inline/autosave save. -------------------------------------------------------------------------------- /All/Dev_Apps/iterm2.md: -------------------------------------------------------------------------------- 1 | # Iterm2 2 | 3 | The best Mac terminal replacement 4 | 5 | | Command | Effect | 6 | | --------- | ----------------------------------------------------------- | 7 | | Cmd-Opt-A | Alert on Finished Command (will see eyeball in upper right) | 8 | | Cmd-Opt-B | See Terminal History | 9 | | | Multiple Screens | 10 | | Ctrl-U | Delete entire cmd line | 11 | | Ctrl-W | Delete last word | 12 | | | | 13 | | | | 14 | | | | 15 | | | | -------------------------------------------------------------------------------- /All/Dev_Apps/matlab.md: -------------------------------------------------------------------------------- 1 | # Matlab/Octave 2 | 3 | Each file is a function, check console to see output and run functions 4 | 5 | IN other files simply call the function name 6 | 7 | You need to add folders to the load path in octave, type `path` into console to see the current files 8 | 9 | Arrays index from 1 10 | 11 | ```matlab 12 | S[:] #pretty sure this turns matrix into vector? 13 | S' #transpose matrix 14 | size(S) #row, column 15 | fprintf('size(A) is %s\n', mat2str(size(A))) 16 | ``` 17 | 18 | ## Operations 19 | 20 | ```matlab 21 | Z ./ 100 # elementwise 100? 22 | ``` 23 | 24 | ## For loops 25 | 26 | Very slow avoid at all costs 27 | 28 | ```matlab 29 | for n=1:10 30 | experiment() 31 | fprintf('%d-Experiment Complete', n); 32 | end 33 | ``` 34 | 35 | ### Octave 36 | 37 | In console, install pkgs with: 38 | 39 | ```matlab 40 | pkg install --forge [package-name] 41 | ``` 42 | 43 | -------------------------------------------------------------------------------- /All/Dev_Apps/notion.md: -------------------------------------------------------------------------------- 1 | # Notion 2 | 3 | Have one master list of tasks then have relations to project and sprints 4 | 5 | Use formulas to create numbers and conditional numbers, then rollups to sum them in the relationed table 6 | 7 | Use linked database to have many pages with different views of the same data 8 | 9 | ### Templates 10 | 11 | - Open Notion Page where you want to use the template 12 | - Create content you want to create a template of 13 | - On the page, type /template to add a template button to the page 14 | - Clear out the existing content in the Template section of the Configure Template box 15 | - Click and Drag the content you want to add to your template into the “Template” section of the Configure Template box -------------------------------------------------------------------------------- /All/Dev_Apps/retool.md: -------------------------------------------------------------------------------- 1 | # Retool 2 | 3 | Create internal database tools very fast 4 | 5 | Can drag drop tables, charts etc 6 | 7 | double brackets can execute arbitrary js including some libraries like moment 8 | 9 | ## Charts 10 | 11 | Add datasets 12 | 13 | -------------------------------------------------------------------------------- /All/Dev_Apps/slack.md: -------------------------------------------------------------------------------- 1 | # Slack 2 | 3 | ## [Github Bot](https://github.com/integrations/slack#configuration) 4 | 5 | ```bash 6 | /github subscribe jsfuentes/Eta commits:all #this should work 7 | /github subscribe jsfuentes/Pi commits:master #but this actually worked :thinking emoji 8 | ``` 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /All/Dev_Apps/tableplus.md: -------------------------------------------------------------------------------- 1 | # Tableplus 2 | 3 | Awesome SQL Admin Tool 4 | 5 | - Lets you easily import from url and query table 6 | - [Backup and restore to move db](https://tableplus.com/blog/2018/04/postgresql-how-to-copy-database-to-other-server.html) -------------------------------------------------------------------------------- /All/Dev_Apps/warp.md: -------------------------------------------------------------------------------- 1 | # Warp 2 | 3 | - Select, filter blocks of output 4 | - click into text 5 | - natural language to commands 6 | - Easy notifs 7 | 8 | Up to 100 AI requests per user per month 9 | 10 | `# explanation of what you want` 11 | 12 | -------------------------------------------------------------------------------- /All/Dev_Apps/windows.md: -------------------------------------------------------------------------------- 1 | # Windows Terminal 2 | 3 | No multiple tabs 4 | 5 | | Cmd | Action | 6 | | ---- | ------ | 7 | | dir | ls | 8 | | cd | Cd | 9 | | | | 10 | | | | 11 | | | | 12 | | | | 13 | | | | 14 | | | | 15 | | | | 16 | 17 | -------------------------------------------------------------------------------- /All/Docker/README.md: -------------------------------------------------------------------------------- 1 | # Docker 2 | 3 | ## Overview 4 | 5 | Get the same environment everywhere. No installation necessary(no onboarding) 6 | 7 | `docker run hello-world` #lists steps as example 8 | 9 | #### Tech Words 10 | 11 | A **container** is an Linux instance launched by running an image. An **image** is an executable package that includes everything needed to run an application--the code, a runtime, libraries, environment variables, and configuration files. 12 | 13 | ## Docker Info 14 | 15 | `docker` | `docker container --help` | `docker -v` | `docker info` 16 | 17 | #### List Stuff 18 | 19 | `docker image ls` #all images locally 20 | 21 | `docker container ls` #all running 22 | `docker container ls --all` #all ever 23 | 24 | ### Clean Up 25 | 26 | ```bash 27 | # clean up any dangling resources(e.g layers unused now) 28 | docker system prune 29 | docker system prune -a # unused images too 30 | ``` -------------------------------------------------------------------------------- /All/Docker/multistage.md: -------------------------------------------------------------------------------- 1 | # Multistage builds 2 | 3 | Can have multiple `FROM` that start new step of build, cleaner than having multiple Dockerfiles 4 | 5 | ```dockerfile 6 | # Stage 1: Build Client 7 | FROM node:10.11.0-alpine as build 8 | WORKDIR /app 9 | 10 | # Install any needed packages specified 11 | COPY ./client/package.json . 12 | COPY ./client/yarn.lock . 13 | RUN yarn install 14 | 15 | # Copy the client contents into the container at /app 16 | COPY ./client . 17 | 18 | # build app 19 | RUN yarn build 20 | 21 | 22 | # Stage 2: Run backend that serves client statically 23 | FROM node:10.11.0-alpine 24 | WORKDIR /app 25 | 26 | # Copy build from previous container 27 | COPY --from=build /app/build /app/build 28 | 29 | # Install backend packages 30 | COPY ./backend/package.json . 31 | COPY ./backend/yarn.lock . 32 | RUN yarn install 33 | 34 | # Copy the backend contents into the container at /app 35 | COPY ./backend . 36 | 37 | EXPOSE 3001 38 | 39 | # Run yarn prod when container launches 40 | CMD ["yarn", "prod"] 41 | ``` 42 | 43 | -------------------------------------------------------------------------------- /All/Elixir/Phoenix/db_ecto/README.md: -------------------------------------------------------------------------------- 1 | # Ecto 2 | 3 | Data validation and db support for postgreSQL, mySQL, MSSQL 4 | 5 | Natural Elixir DSL/query engine to query abs 6 | 7 | Need to setup credentials in `config/dev.exs` 8 | 9 | -------------------------------------------------------------------------------- /All/Elixir/Phoenix/file_structure.md: -------------------------------------------------------------------------------- 1 | # Default File Structure 2 | 3 | - Can make a plug folder in web and then include in router.ex 4 | - Can import things in discuss_web.ex that will then be available in all views/controllers 5 | 6 | ├── build 7 | ├── assets 8 | ├── config 9 | ├── deps 10 | ├── lib 11 | └── hello 12 | └── hello_web 13 | └── hello.ex 14 | └── hello_web.ex 15 | ├── priv 16 | ├── test 17 | 18 | Lib/hello_web 19 | 20 | ``` 21 | ├── channels 22 | │ └── user_socket.ex 23 | ├── controllers 24 | │ └── page_controller.ex 25 | ├── templates 26 | │ ├── layout 27 | │ │ └── app.html.eex 28 | │ └── page 29 | │ └── index.html.eex 30 | └── views 31 | │ ├── error_helpers.ex 32 | │ ├── error_view.ex 33 | │ ├── layout_view.ex 34 | │ └── page_view.ex 35 | ├── endpoint.ex 36 | ├── gettext.ex 37 | ├── router.ex 38 | ``` 39 | 40 | -------------------------------------------------------------------------------- /All/Elixir/Phoenix/liveview.md: -------------------------------------------------------------------------------- 1 | # LiveView 2 | 3 | Severside rendering of components that uses sockets to automatically push data updates 4 | 5 | ```bash 6 | mix phx.new my_app --live 7 | ``` 8 | 9 | -------------------------------------------------------------------------------- /All/Elixir/Phoenix/packages/corsplug.md: -------------------------------------------------------------------------------- 1 | # CorsPlug 2 | 3 | ```elixir 4 | {:cors_plug, "~> 1.5"}, 5 | ``` 6 | 7 | -------------------------------------------------------------------------------- /All/Elixir/Phoenix/testing.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | ```elixir 4 | defmodule KVTest do 5 | use ExUnit.Case 6 | doctest KV 7 | 8 | test "greets the world" do 9 | assert KV.hello() == :world 10 | end 11 | end 12 | ``` 13 | 14 | ```bash 15 | mix test 16 | ``` -------------------------------------------------------------------------------- /All/Elixir/Phoenix/token.md: -------------------------------------------------------------------------------- 1 | # [Phoenix.Token](https://hexdocs.pm/phoenix/Phoenix.Token.html) 2 | 3 | Phoenix built-in generate and verify signed tokens(not encrypted, so can verify data was signed not hide data) 4 | 5 | ```elixir 6 | user_id = 1 7 | token = Phoenix.Token.sign(ReactPhoenixWeb.Endpoint, "user auth", user_id) 8 | Phoenix.Token.verify(ReactPhoenixWeb.Endpoint, "user auth", token, max_age: 86400) #{:ok, 1} 9 | ``` 10 | 11 | Arg 1: Uses the secret key base configured in the endpoint 12 | 13 | Arg 2: [cryptographic salt](https://en.wikipedia.org/wiki/Salt_(cryptography)), kinda like a namespace 14 | 15 | ^Must be same in sign and verify 16 | 17 | Arg 3: What to codify in the string 18 | 19 | ## Extra 20 | 21 | Also has `encrypt` and `decrypt` 22 | 23 | -------------------------------------------------------------------------------- /All/Elixir/collections/set.md: -------------------------------------------------------------------------------- 1 | # [Set](https://hexdocs.pm/elixir/1.12/MapSet.html) 2 | 3 | ```elixir 4 | MapSet.new([2]) |> MapSet.put(4) |> MapSet.put(0) 5 | #MapSet<[0, 2, 4]> 6 | 7 | MapSet.member?(MapSet.new([1, 2, 3]), 2) 8 | ``` 9 | 10 | Get unique elements from list 11 | 12 | ```elixir 13 | list |> MapSet.new |> MapSet.to_list 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /All/Elixir/collections/strings.md: -------------------------------------------------------------------------------- 1 | # [String](https://hexdocs.pm/elixir/String.html#summary) 2 | 3 | ```elixir 4 | "hello" 5 | "string" <> "concat" 6 | 7 | x = 123 8 | x <> "hi" #error 9 | "#{x}hi" #123hi 10 | ``` 11 | 12 | String.reverse(str) 13 | 14 | String.upcase(str) 15 | 16 | String.downcase(str) 17 | 18 | String.capitalize(str) 19 | 20 | String.starts_with?(str) 21 | 22 | String.contains?(str, "search_str") 23 | 24 | String.first(str) 25 | 26 | String.at(str, index) 27 | 28 | String.slice(str, start_index, end_index) 29 | 30 | String.split("foo bar", "") 31 | 32 | String.length("foo bar") 33 | 34 | ### Atoms 35 | 36 | An atom is a constant whose value is its own name 37 | 38 | `true`, `false`, and `nil` are atoms, but can skip `:` 39 | 40 | ```elixir 41 | :apple 42 | :ok != :error 43 | :true == true 44 | is_atom(false) # => true 45 | true and true 46 | false or not true 47 | 1 and true # => raises exception 48 | Atom.to_string(:foo) 49 | ``` 50 | 51 | _Atoms are not garbage collected, so never convert user input to atoms_ 52 | 53 | -------------------------------------------------------------------------------- /All/Elixir/collections/structs.md: -------------------------------------------------------------------------------- 1 | # Structs 2 | 3 | Structs are extensions built on top of maps that provide default values and compile-time guarantees that only the defined fields exist. 4 | 5 | Structs are **bare** maps which means you can't enumerate or [] a struct. But you can use `Map.` functions 6 | 7 | ### Creating 8 | 9 | ```elixir 10 | defmodule User do 11 | defstruct name: "John", age: 27 12 | end 13 | ``` 14 | 15 | ```elixir 16 | iex> %User{} 17 | %User{age: 27, name: "John"} 18 | iex> %User{name: "Jane"} 19 | %User{age: 27, name: "Jane"} 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /All/Elixir/collections/tuple.md: -------------------------------------------------------------------------------- 1 | # Tuples 2 | 3 | Can hold any value, but not for enumeration 4 | 5 | Arrays continuous in memory, but new ones require new continuous memory. Contents aren't copied, contents are shared 6 | 7 | ```elixir 8 | my_stats = {175, 5.25, :Derek} 9 | IO.puts "Tuple ${is_tuple(my_stats)}" 10 | my_stats2 = Tuple.append(my_stats, 42) 11 | IO.puts "Age: #{elem(my_stats2, 3)}" 12 | IO.puts "Size: #{tuple_size(my_stats2, 3)}" 13 | my_stats3 = Tuple.delete_at(my_stats2, 0) 14 | my_stats4 = Tuple.insert_at(my_stats3, 0, 1974) 15 | many_zeroes = Tuple.duplicate(0, 5) 16 | 17 | {weight, height, name} = {175, 6.25, "Derek"} 18 | IO.puts "Weight: #{weight}" 19 | ``` 20 | 21 | #### Turn List of Tuples Into A Map 22 | 23 | ```elixir 24 | [a: 1, b: 2] |> Enum.into(%{}) #%{a: 1, b: 2} 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /All/Elixir/config.md: -------------------------------------------------------------------------------- 1 | # Config 2 | 3 | Each application has its own environment. 4 | 5 | `config/config.exs` is base of every project 6 | 7 | config/dev.exs 8 | 9 | ```elixir 10 | import_config "dev.secret.exs" 11 | ``` 12 | 13 | config/dev.secrets.exs 14 | 15 | ```elixir 16 | use Mix.Config 17 | 18 | config :sonar, 19 | google: "fasfdajkl" 20 | ``` 21 | 22 | #### Usage 23 | 24 | ```elixir 25 | Application.fetch_env!(:sonar, :google) 26 | Application.get_env(:sonar, :google, :default) #allows default and no error if key doesn't exist 27 | ``` 28 | 29 | ### Based on env 30 | 31 | ```elixir 32 | if Mix.env() == :dev do 33 | #... can even be in router 34 | end 35 | ``` 36 | 37 | ## Runtime.ex vs Prod.ex 38 | 39 | Simply: 40 | 41 | - `releases.exs` - runtime configuration for `release` **only** 42 | - `#{Mix.env()}.exs` - i.e. `dev.exs`, `prod.exs`, `test.exs` - those are compiletime environment-specific configuration files 43 | - `config.exs` - compiletime generic configuration file 44 | - `releases.exs` - runtime generic configuration file 45 | -------------------------------------------------------------------------------- /All/Elixir/erlang.md: -------------------------------------------------------------------------------- 1 | # Erlang 2 | 3 | Built by telecoms systems(Ericson in 1970s ) and run most of the worlds communications(5 9's more with Erlang) 4 | 5 | Erlang is highly scalable and lightweight, like can be its own OS on very lightweight systems(100x smaller/startup time) 6 | 7 | Very reliablity b/c not general purpose, runs threadlike erlang code only(scales linear up to 50 cores) 8 | 9 | Each process runs 1000 cycles then gives up, processes can't block or anything. So multicores parallelism, balancing across cores, and adding more processes is trivial and automatic. Can take yourself out of rotation while waiting for messages(IO too). And rebooting when process crash is automatic. Low latecny over throughput. 10 | 11 | ### OTP 12 | 13 | Supervisor looks over Genserver 14 | 15 | Erlang used by Heroku, WhatsApp(2 million connections on a single machine); 16 | 17 | -------------------------------------------------------------------------------- /All/Elixir/file.md: -------------------------------------------------------------------------------- 1 | # File 2 | 3 | - Mostly named after UNIX equivalents like rm/1, mkdir/1, mkdir_p/1, cp_r/2, rm_rf/1 4 | - Two variants, one regular and one with trailing bang. Use bang if you don't handle error 5 | 6 | Get raw contents 7 | 8 | ```elixir 9 | case File.read(file) do 10 | {:ok, body} -> # do something with the `body` 11 | {:error, reason} -> # handle the error caused by `reason` 12 | end 13 | File.read!("existing") # "... contents ..." 14 | File.read!("unknown") #**(File.Error) ... 15 | ``` 16 | 17 | Open for read and write 18 | 19 | ```elixir 20 | {:ok, file} = File.open("hello", [:write]) # {:ok, #PID<0.47.0>} 21 | IO.binwrite(file, "world") #:ok 22 | File.close(file) #:ok 23 | File.read("hello") #{:ok, "world"} 24 | ``` 25 | 26 | ## Path 27 | 28 | ```elixir 29 | iex> Path.join("foo", "bar") 30 | "foo/bar" 31 | iex> Path.expand("~/hello") 32 | "/Users/jose/hello" 33 | ``` 34 | 35 | -------------------------------------------------------------------------------- /All/Elixir/math.md: -------------------------------------------------------------------------------- 1 | # Math 2 | 3 | All ops normal, except `/` always returns float 4 | 5 | div(5, 4) is integer division => 1 6 | 7 | rem(5, 4) is modulo => 1 8 | 9 | Float, Integer different and different libs 10 | 11 | Kernel has functions that work on many 12 | 13 | ```elixir 14 | easiness_factor = (card.easiness_factor + (0.1 - (5 - q) * (0.08 + (5 - q) * 0.02))) |> Float.round(3) |> Kernel 15 | ``` 16 | 17 | ## Kernel 18 | 19 | - .min 20 | - .max 21 | - .round - to nearest integer 22 | 23 | Random Number 24 | 25 | ```elixir 26 | :rand.uniform(n) #1-n inclusive 27 | ``` 28 | 29 | -------------------------------------------------------------------------------- /All/Elixir/modules.md: -------------------------------------------------------------------------------- 1 | # [Modules](https://hexdocs.pm/elixir/master/Module.html) 2 | 3 | ```elixir 4 | # Alias the module so it can be called as Bar instead of Foo.Bar 5 | alias Foo.Bar, as: Bar 6 | alias Foo.Bar #defaults to name after .(Bar) 7 | # Require the module in order to use its macros 8 | require Foo 9 | # Import functions from Foo so they can be called without the `Foo.` prefix 10 | import Foo 11 | # Invokes the custom code defined in Foo as an extension point 12 | use Foo 13 | ``` 14 | 15 | ## Attributes 16 | 17 | #### Impl 18 | 19 | When you use a module then want to implement the functions you can use `@impl true` to indicate what you think a callback is, it will do typechecking matching it 20 | 21 | - Will error if you do it once and not every time 22 | 23 | ```elixir 24 | @impl true 25 | def init(state) do 26 | {:ok, state} 27 | end 28 | 29 | @impl true 30 | def start_link do 31 | GenServer.start_link(__MODULE__, 0) 32 | end 33 | ``` 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /All/Elixir/packages/README.md: -------------------------------------------------------------------------------- 1 | # Packages 2 | 3 | To add a package, you need to add a line to 4 | 5 | mix.exs 6 | 7 | ```elixir 8 | defp deps do 9 | [ 10 | #..... 11 | {:plug_cowboy, "~> 2.0"}, 12 | {:httpoison, "~> 1.6"} 13 | ] 14 | end 15 | ``` 16 | 17 | Then run `mix deps.get` 18 | 19 | ### Version 20 | 21 | ```elixir 22 | # Only version 2.0.0 23 | "== 2.0.0" 24 | 25 | # Anything later than 2.0.0 26 | "> 2.0.0" 27 | 28 | # 2.0.0 and later until 2.1.0 29 | ">= 2.0.0 and < 2.1.0" 30 | # Equivalent to 31 | "~> 2.0.0" 32 | ``` 33 | 34 | ### [Updating](https://inquisitivedeveloper.com/lwm-elixir-58/) 35 | 36 | ```bash 37 | mix hex.outdated #to see what packages have newer versions 38 | mix deps.update --all #updates minor versions of all deps 39 | # Need to manually change mix.exs to update major version 40 | ``` 41 | 42 | ### Packages of Interest 43 | 44 | - [guardian](https://github.com/ueberauth/guardian) 45 | - Genstage, broadway 46 | -------------------------------------------------------------------------------- /All/Elixir/packages/geolix.md: -------------------------------------------------------------------------------- 1 | # Geolix 2 | 3 | With geolix you can do ip address to location mapping 4 | 5 | ## Setup 6 | 7 | 1) Get links to mmbd2 database [here](https://www.maxmind.com/en/geolite2/thank-you), you will have to make an account and generate a license link 8 | 9 | 2) Install deps 10 | 11 | ```elixir 12 | {:geolix, "~> 2.0"}, 13 | {:geolix_adapter_mmdb2, "~> 0.6.0"}, 14 | ``` 15 | 16 | 3) Config 17 | 18 | ```elixir 19 | config :geolix, databases: [ 20 | %{ 21 | id: :city, 22 | adapter: Geolix.Adapter.MMDB2, 23 | source: "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=LICEN_SEKY&suffix=tar.gz" 24 | }, 25 | %{ 26 | id: :country, 27 | adapter: Geolix.Adapter.MMDB2, 28 | source: "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=LICEN_SEKY&suffix=tar.gz" 29 | } 30 | ] 31 | ``` 32 | 33 | ## Usage 34 | 35 | ```elixir 36 | Geolix.lookup("45.50.161.38") 37 | ``` 38 | 39 | -------------------------------------------------------------------------------- /All/Elixir/packages/http/http.md: -------------------------------------------------------------------------------- 1 | # HTTP 2 | 3 | Look into [Tesla](https://hexdocs.pm/tesla/readme.html) as its a general wrapper around all these underlying clients 4 | 5 | 6 | 7 | https://elixirforum.com/t/mint-vs-finch-vs-gun-vs-tesla-vs-httpoison-etc/38588/11 -------------------------------------------------------------------------------- /All/Elixir/packages/json.md: -------------------------------------------------------------------------------- 1 | ## Jason 2 | 3 | ```elixir 4 | {:jason, "~> 1.2"} 5 | ``` 6 | 7 | ## Usage 8 | 9 | ```elixir 10 | Jason.encode!(%{"age" => 44, "name" => "Steve Irwin", "nationality" => "Australian"}) 11 | #"{\"age\":44,\"name\":\"Steve Irwin\",\"nationality\":\"Australian\"}" 12 | 13 | Jason.decode!(~s({"age":44,"name":"Steve Irwin","nationality":"Australian"})) 14 | #%{"age" => 44, "name" => "Steve Irwin", "nationality" => "Australian"} 15 | ``` 16 | 17 | ### Worse JSON 18 | 19 | ```elixir 20 | {:json, "~> 1.2"} 21 | ``` 22 | 23 | #### Usage 24 | 25 | ```elixir 26 | {status, result} = JSON.encode(list) 27 | 28 | json_input = "{\"key\":\"this will be a value\"}" 29 | {status, list} = JSON.decode(json_input) 30 | ``` 31 | 32 | -------------------------------------------------------------------------------- /All/Elixir/packages/nanoid.md: -------------------------------------------------------------------------------- 1 | # [Nanoid](https://github.com/railsmechanic/nanoid) 2 | 3 | A port of nodes nano_id which is a small, url safe, id generator that is better than uuid because it uses more letters allowing it to be 21 letters instead of 36. 4 | 5 | ```elixir 6 | {:nanoid, "~> 2.0.2"}, 7 | ``` 8 | 9 | 10 | 11 | ```elixir 12 | Nanoid.generate(12) 13 | ``` 14 | 15 | -------------------------------------------------------------------------------- /All/Elixir/packages/stripe.md: -------------------------------------------------------------------------------- 1 | # Stripe 2 | 3 | ```elixir 4 | {:stripity_stripe, "~> 2.0"} 5 | ``` 6 | 7 | -------------------------------------------------------------------------------- /All/Elixir/packages/swoosh.md: -------------------------------------------------------------------------------- 1 | # Swoosh 2 | 3 | Might come with phoenix now unclear 4 | 5 | Config.exs 6 | 7 | ```elixir 8 | # Configures the mailer 9 | config :react_phoenix, ReactPhoenix.Mailer, 10 | adapter: Swoosh.Adapters.Postmark, 11 | api_key: System.get_env("POSTMARK_API_KEY") 12 | 13 | # Swoosh API client is needed for adapters other than SMTP. 14 | config :swoosh, :api_client, Swoosh.ApiClient.Hackney 15 | ``` 16 | 17 | ReactPhoenix.Mailer 18 | 19 | ```elixir 20 | defmodule ReactPhoenix.Mailer do 21 | use Swoosh.Mailer, otp_app: :react_phoenix 22 | end 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /All/Elixir/time.md: -------------------------------------------------------------------------------- 1 | # Time 2 | 3 | See timex for more advanced stuff 4 | 5 | #### DateTime 6 | 7 | Utc_now is the same type as timestamps from db 8 | 9 | ```elixir 10 | now = DateTime.utc_now() #~U[2020-12-07 01:09:48.868084Z] 11 | nowUTC = DateTime.utc_now() |> DateTime.to_unix() #1607303503 12 | ``` 13 | 14 | Compare 15 | 16 | ```elixir 17 | def is_current_subevent(se) do 18 | now = DateTime.utc_now() 19 | start_cmp = DateTime.compare(now, se.start_time) 20 | end_cmp = DateTime.compare(now, se.end_time) 21 | start_cmp === :gt && end_cmp === :lt 22 | end 23 | ``` 24 | 25 | #### Naive DateTime 26 | 27 | ```elixir 28 | now = NaiveDateTime.utc_now() 29 | # 7 hour diff PST, so 19 30 | tomorrow_noon = 31 | NaiveDateTime.new(now.year, now.month, now.day, 19, 0, 0) 32 | |> (fn {:ok, d} -> d end).() 33 | |> NaiveDateTime.add(60 * 60 * 24, :second) 34 | 35 | tomorrow_one = tomorrow_noon |> NaiveDateTime.add(60 * 60, :second) 36 | ``` 37 | 38 | #### Erlang Standard 39 | 40 | Get current time with `:calendar.universal_time()` or `:calendar.local_time()` 41 | 42 | -------------------------------------------------------------------------------- /All/Elixir/uri.md: -------------------------------------------------------------------------------- 1 | # URI 2 | 3 | ```elixir 4 | uri_string = 5 | base_url 6 | |> URI.parse() 7 | |> Map.put(:query, URI.encode_query(params)) 8 | |> URI.to_string() 9 | ``` 10 | 11 | -------------------------------------------------------------------------------- /All/Go/.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsfuentes/Code-Cheatsheet/30a9cd5ee04200b17ec711d162d8714bb3b7b550/All/Go/.md -------------------------------------------------------------------------------- /All/Go/assert.md: -------------------------------------------------------------------------------- 1 | # Assert 2 | 3 | `import "github.com/stretchr/testify/assert"` 4 | 5 | ### Basic Example 6 | 7 | ```go 8 | import ( 9 | "testing" 10 | "github.com/stretchr/testify/assert" 11 | ) 12 | 13 | func TestSomething(t *testing.T) { 14 | assert.Equal(t, "Hi", "Hi", "The two words should be the same.") 15 | } 16 | ``` 17 | 18 | ## Common 19 | 20 | - .Equal 21 | - .Error 22 | - .NoError 23 | - .True 24 | - .False -------------------------------------------------------------------------------- /All/Go/collections/README.md: -------------------------------------------------------------------------------- 1 | ## Collections 2 | 3 | len([some col]) 4 | 5 | Go passes a copy of collections by default 6 | 7 | `sort` package has sorting e.g `sort.Strings([collection])` 8 | 9 | ### Iteration 10 | 11 | ```go 12 | for i := range colors { //set i to current index 13 | fmt.Println(colors[i]) 14 | } 15 | ``` 16 | 17 | ## usage 18 | 19 | - `len(colors)` 20 | 21 | -------------------------------------------------------------------------------- /All/Go/collections/maps.md: -------------------------------------------------------------------------------- 1 | ## Maps 2 | 3 | Create 4 | 5 | ```go 6 | var states map[string]string 7 | states := make(map[string]string) 8 | commits := map[string]int{ 9 | "rsc": 3711, 10 | "r": 2138, 11 | "gri": 1908, 12 | "adg": 912, 13 | } 14 | ``` 15 | 16 | Get and set 17 | 18 | ```go 19 | states["CA"] = "California" 20 | california := states["CA"] 21 | cal, ok := s["CCCC"] //opt ok 22 | ``` 23 | 24 | - if the key does not exist, then the zero of the value type is returned(0 for int, "" for string) and ok is false 25 | 26 | Delete 27 | 28 | ```go 29 | delete(states, "CA") //[] 30 | ``` 31 | 32 | Iterate 33 | 34 | ```go 35 | for k, v := range states { 36 | fmt.Printf("%v, %v\n", k, v) 37 | } 38 | ``` 39 | 40 | List 41 | 42 | ```go 43 | key := make([]string, len(states)) 44 | i := 0 45 | for k := range states { 46 | keys[i] = k 47 | i++ 48 | } 49 | ``` 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /All/Go/dep.md: -------------------------------------------------------------------------------- 1 | # Go Get Vs Dep 2 | 3 | - go get more for consumers of go code 4 | - dep for developers to manage version and the like 5 | 6 | ## Go Get 7 | 8 | ### Installation 9 | 10 | `go get github.com/tensorflow/tensorflow/tensorflow/go` 11 | 12 | Fetch, build, and install remote package into workspace defined by $GOPATH \ 13 | 14 | ### Usage 15 | 16 | ```go 17 | package main 18 | 19 | import ( 20 | tf "github.com/tensorflow/tensorflow/tensorflow/go" //access with tf. 21 | "github.com/tensorflow/tensorflow/tensorflow/go/op" //access with op. 22 | "fmt" 23 | ) 24 | 25 | func main() { 26 | // Construct a graph with an operation that produces a string constant. 27 | s := op.NewScope() 28 | c := op.Const(s, "Hello from TensorFlow version " + tf.Version()) 29 | } 30 | ``` 31 | 32 | -------------------------------------------------------------------------------- /All/Go/interfaces.md: -------------------------------------------------------------------------------- 1 | ## Interfaces 2 | 3 | No keyword like extends, if you implement all the methods then you can be that type 4 | 5 | So everything is the empty `interface{}` 6 | 7 | ```go 8 | type Animal interface { 9 | Speak() string 10 | } 11 | ``` 12 | 13 | ### Usage 14 | 15 | ```go 16 | type Dog struct { 17 | //... 18 | } 19 | 20 | func (d Dog) Speak() string { 21 | return "Woof" 22 | } 23 | 24 | func main() { 25 | poodle:= Animal(Dog()) //cast as Animal 26 | } 27 | ``` 28 | 29 | ## The empty interface 30 | 31 | - Specifies no methods 32 | - May hold values of any type like fmt.Println 33 | 34 | ``` 35 | interface{} 36 | ``` 37 | 38 | An empty interface may hold values of any type. (Every type implements at least zero methods.) -------------------------------------------------------------------------------- /All/Go/math.md: -------------------------------------------------------------------------------- 1 | # Math 2 | 3 | common ops 4 | 5 | ```go 6 | var int1 int = 5 7 | var float1 float64 = 42 8 | sum := float64(int1) + float1 9 | ``` 10 | 11 | #### `math` packageeee 12 | 13 | math.Pi 14 | 15 | #### Big Num to get precision 16 | 17 | ```go 18 | import "math/big" 19 | 20 | var b1, b2, b3, bigSum big.Float 21 | b1.SetFloat64(23.5) 22 | b2.SetFloat64(65.1) 23 | b3.SetFloat64(76.3) 24 | 25 | bigSum.Add(&b1, &b2).Add(&bigSum, &b3) 26 | fmt.Printf("BigSum = %.10g\n", &bigSum) 27 | ``` 28 | 29 | ### Converstion 30 | 31 | ```go 32 | price, _, _ := big.ParseFloat(p, 10, 2, big.ToZero) //base 10, precision 2, rounding mode tozero 33 | ``` 34 | 35 | -------------------------------------------------------------------------------- /All/Go/request.md: -------------------------------------------------------------------------------- 1 | # Request 2 | 3 | ```go 4 | import ( 5 | "fmt" 6 | "net/http" 7 | "io/ioutil" 8 | ) 9 | ``` 10 | 11 | Get returns http.Response 12 | 13 | ```go 14 | resp, err := http.Get(url) 15 | checkErr(err) 16 | 17 | fmt.Printf("Response type: %T\n", resp) 18 | ``` 19 | 20 | ### Work with Data 21 | 22 | ```go 23 | resp, err := http.Get(url) 24 | checkErr(err) 25 | 26 | defer resp.Body.Close() 27 | 28 | bytes, err := ioutil.ReadAll(resp.Body) 29 | checkErr(err) 30 | 31 | content := string(bytes) 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /All/Go/server.md: -------------------------------------------------------------------------------- 1 | # Simple Server 2 | 3 | ```go 4 | import ( 5 | "fmt" 6 | "net/http" 7 | ) 8 | ``` 9 | 10 | 11 | 12 | ## Serving 13 | 14 | Have a struct that has a func, ServeHTTP will be called to service requests 15 | 16 | ```go 17 | type Hello struct {} 18 | 19 | func (h Hello) ServeHTTP(w http.ResponseWriter, r *http.Request) { 20 | fmt.Fprint(w, "