├── ML ├── .md ├── eval_llm.md ├── NLP │ ├── nltk.md │ └── Overview.md ├── Deploy │ ├── Beam.md │ └── Paperspace.md └── lowlevel │ └── Regularization.md ├── All ├── Go │ ├── .md │ ├── collections │ │ ├── README.md │ │ └── maps.md │ ├── assert.md │ ├── testing.md │ ├── request.md │ ├── server.md │ ├── math.md │ ├── interfaces.md │ ├── time.md │ ├── dep.md │ └── structs.md ├── Elixir │ ├── packages │ │ ├── stripe.md │ │ ├── http │ │ │ └── http.md │ │ ├── nanoid.md │ │ ├── swoosh.md │ │ ├── json.md │ │ ├── README.md │ │ └── geolix.md │ ├── Phoenix │ │ ├── packages │ │ │ └── corsplug.md │ │ ├── liveview.md │ │ ├── db_ecto │ │ │ └── README.md │ │ ├── testing.md │ │ ├── token.md │ │ └── file_structure.md │ ├── uri.md │ ├── collections │ │ ├── set.md │ │ ├── structs.md │ │ ├── tuple.md │ │ └── strings.md │ ├── math.md │ ├── erlang.md │ ├── file.md │ ├── modules.md │ ├── config.md │ └── time.md ├── HTML │ ├── Fun.md │ ├── scripts.md │ ├── favicon.md │ ├── Templating │ │ └── README.md │ ├── optimizations.md │ └── SEO.md ├── Bash │ ├── man.md │ ├── installed │ │ ├── generact.md │ │ ├── ngrok.md │ │ ├── nvm.md │ │ └── spell.md │ ├── Kill.md │ ├── ssh.md │ ├── diff.md │ ├── sed.md │ ├── find.md │ ├── vi.md │ ├── Makefile.md │ ├── general.md │ ├── sftp.md │ ├── emacs.md │ └── metadata.md ├── Php │ ├── Hack.md │ ├── AMP.md │ └── requests.md ├── Databases │ ├── hosts.md │ ├── tips.md │ ├── redis.md │ ├── SQL │ │ ├── sqllite.md │ │ ├── aggregate.md │ │ ├── joins.md │ │ └── optimizations.md │ ├── advanced.md │ └── libs.md ├── APIS │ ├── Stripe.md │ ├── DuckDuckGo.md │ └── README.md ├── Python │ ├── flask │ │ ├── cli.md │ │ ├── postgres │ │ │ ├── README.md │ │ │ └── migrate.md │ │ ├── packages │ │ │ └── cors.md │ │ ├── flash.md │ │ ├── packages.md │ │ ├── deploying.md │ │ ├── blueprint.md │ │ ├── README.md │ │ └── response.md │ ├── packages │ │ ├── pillow.md │ │ ├── excel.md │ │ ├── pydub.md │ │ ├── passwords.md │ │ ├── dotenv.md │ │ ├── jupyter.md │ │ ├── cython.md │ │ ├── prisma.md │ │ ├── matplotlib.md │ │ └── pandas.md │ ├── advanced.md │ ├── random.md │ ├── Django │ │ ├── db.md │ │ ├── router.md │ │ ├── serializers.md │ │ ├── packages │ │ │ └── django-environ.md │ │ └── views.md │ ├── collections │ │ ├── set.md │ │ ├── dict.md │ │ ├── fancyDicts.md │ │ ├── README.md │ │ ├── heap.md │ │ └── list.md │ ├── crypto.md │ ├── json.md │ ├── classes.md │ ├── argparse.md │ ├── re.md │ └── testing.md ├── Dev_Apps │ ├── tableplus.md │ ├── warp.md │ ├── retool.md │ ├── slack.md │ ├── windows.md │ ├── notion.md │ ├── matlab.md │ └── iterm2.md ├── CS_Fundamentals │ ├── Microservices.md │ ├── ErrorHandling.md │ ├── Concurrency.md │ ├── Email.md │ ├── Webhook.md │ ├── Encryption.md │ ├── Sorting.md │ ├── Testing.md │ ├── Optimization.md │ ├── WebRTC.md │ ├── StoringSecrets.md │ ├── Real-Time.md │ ├── FeatureFlags.md │ └── Password_Hashing.md ├── Scala │ ├── packages.md │ ├── objects.md │ ├── exceptions.md │ ├── performance&style.md │ ├── traits.md │ ├── subtyping.md │ ├── options.md │ └── sbt(running).md ├── C++ │ └── ptrs.md ├── Docker │ ├── README.md │ └── multistage.md └── solana.md ├── Deployment ├── Github │ └── README.md ├── DigitalOcean.md ├── loadtesting.md ├── AWS │ ├── Storage │ │ ├── CustomEC2.md │ │ ├── Autoscaling.md │ │ ├── DynamoDB.md │ │ ├── README.md │ │ └── Aurora.md │ ├── SES.md │ ├── ACM.md │ ├── EC2 │ │ └── README.md │ ├── Cloudwatch.md │ ├── Codepipeline.md │ ├── Lambda.md │ ├── Docker.md │ ├── IAM.md │ ├── SQS.md │ ├── VPC.md │ ├── ELB.md │ ├── zappa.md │ └── Cloudfront.md ├── Cloud GPUS │ ├── paperspace.md │ └── replicate.md ├── redis.md ├── sockets.md ├── speed_opt.md ├── GCP │ ├── README.md │ ├── Network.md │ └── Compute.md ├── surge.md ├── cloudflare.md ├── processManagement.md └── vercel.md ├── JS ├── All │ ├── Electron │ │ ├── notarizing.md │ │ ├── packages │ │ │ ├── README.md │ │ │ ├── sentry.md │ │ │ ├── electron-log.md │ │ │ ├── electron-is-dev.md │ │ │ └── forge.md │ │ ├── image.md │ │ ├── dialog.md │ │ ├── multiplatform.md │ │ ├── renderer.md │ │ ├── messages.md │ │ ├── deeplinks.md │ │ └── tray.md │ ├── Node │ │ ├── env.md │ │ ├── packages │ │ │ ├── dotenv.md │ │ │ ├── crypto.md │ │ │ └── commander.md │ │ ├── setup.md │ │ ├── logging.md │ │ ├── middleware.md │ │ ├── req.md │ │ ├── forms.md │ │ ├── ejs.md │ │ └── res.md │ ├── Chrome_Plugins │ │ ├── url_match.md │ │ ├── deploying.md │ │ ├── browser_action.md │ │ ├── shortcuts.md │ │ ├── README.md │ │ ├── events.md │ │ ├── context_menu.md │ │ ├── tabs.md │ │ └── setup.md │ ├── Angular │ │ ├── input.md │ │ ├── bash.md │ │ └── typescript.md │ └── bun.md ├── typescript │ ├── utility.md │ ├── enum.md │ ├── migration.md │ ├── generics.md │ └── README.md ├── webJS │ ├── simpleserve.md │ ├── DOMShadow.md │ ├── packages │ │ ├── videojs.md │ │ ├── bowser.md │ │ └── boxicons.md │ ├── keyboard.md │ ├── scroll.md │ ├── README.md │ ├── CORS.md │ └── cookies.md ├── packages │ ├── lodash.md │ ├── node-sass.md │ ├── concurrently.md │ ├── query-string.md │ ├── cheerio.md │ ├── csv-parser.md │ ├── trpc.md │ ├── prettier.md │ └── bcrypt.md ├── bundlers │ ├── vite.md │ └── parcel.md ├── timeout.md ├── collections │ ├── string.md │ ├── set.md │ ├── JSON.md │ └── blob.md ├── closure.md └── debugging.md ├── .gitignore ├── React ├── All │ ├── Gatsby │ │ ├── transformer.md │ │ ├── pages.md │ │ ├── setup.md │ │ ├── link.md │ │ ├── cli.md │ │ └── packages │ │ │ └── mdx.md │ ├── React_Native │ │ ├── Expo │ │ │ ├── env.md │ │ │ ├── development_build.md │ │ │ ├── README.md │ │ │ └── setup.md │ │ ├── orientation.md │ │ ├── packages │ │ │ └── screenshot.md │ │ └── width_height.md │ └── Prehooks │ │ ├── components.md │ │ └── ref.md ├── Next │ ├── packages │ │ └── mdx.md │ ├── config.md │ ├── setup.md │ ├── app_router.md │ ├── PreAppRouter │ │ └── head.md │ └── deploying.md ├── data_loading │ └── README.md ├── packages │ ├── shadcn.md │ ├── fluxible.md │ ├── feather.md │ ├── general.md │ ├── intersection-observer.md │ ├── SWR.md │ ├── color.md │ ├── telephone.md │ ├── draggable.md │ ├── classnames.md │ └── xstate.md └── state_management │ ├── redux │ ├── middleware.md │ ├── README.md │ └── immer.md │ ├── README.md │ └── jotai.md ├── CSS ├── cursors.md ├── placement │ ├── columns.md │ ├── position.md │ └── README.md ├── colors.md ├── display.md ├── lists.md ├── tailwind │ ├── typography.md │ ├── position.md │ ├── media_queries.md │ └── size_spacing.md ├── object-fit.md ├── fonts.md └── README.md ├── typora.md ├── mac.md ├── Rust ├── Importing.md └── Error.md ├── regex.md ├── google.md └── debugging.md /ML/.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /All/Go/.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ML/eval_llm.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Deployment/Github/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /JS/All/Electron/notarizing.md: -------------------------------------------------------------------------------- 1 | Need many things -------------------------------------------------------------------------------- /Deployment/DigitalOcean.md: -------------------------------------------------------------------------------- 1 | # Digital Ocean 2 | 3 | -------------------------------------------------------------------------------- /Deployment/loadtesting.md: -------------------------------------------------------------------------------- 1 | https://loader.io/ - free load testing by sendgrid -------------------------------------------------------------------------------- /JS/typescript/utility.md: -------------------------------------------------------------------------------- 1 | # Utility Types 2 | 3 | - Partial 4 | - Pick 5 | - Omit -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Ecstatic/ 2 | .DS_Store 3 | Coursera/ 4 | Facebook/ 5 | Latent/ 6 | latent.md 7 | *~* 8 | -------------------------------------------------------------------------------- /Deployment/AWS/Storage/CustomEC2.md: -------------------------------------------------------------------------------- 1 | # Make DB in EC2 2 | 3 | Just run your custom DB in EC2 4 | 5 | -------------------------------------------------------------------------------- /All/Elixir/packages/stripe.md: -------------------------------------------------------------------------------- 1 | # Stripe 2 | 3 | ```elixir 4 | {:stripity_stripe, "~> 2.0"} 5 | ``` 6 | 7 | -------------------------------------------------------------------------------- /Deployment/AWS/SES.md: -------------------------------------------------------------------------------- 1 | # Simple Email Service 2 | 3 | Cheap at only .1/1000 email and pay as you go 4 | 5 | -------------------------------------------------------------------------------- /All/HTML/Fun.md: -------------------------------------------------------------------------------- 1 | ## Fun Useless Tags 2 | 3 |
//horizontal line 4 | hi //scrolling line -------------------------------------------------------------------------------- /ML/NLP/nltk.md: -------------------------------------------------------------------------------- 1 | # NLTK 2 | 3 | `nltk.download()` 4 | 5 | ## Notable Functions 6 | - tokenize 7 | - pos_tag 8 | -------------------------------------------------------------------------------- /All/Elixir/Phoenix/packages/corsplug.md: -------------------------------------------------------------------------------- 1 | # CorsPlug 2 | 3 | ```elixir 4 | {:cors_plug, "~> 1.5"}, 5 | ``` 6 | 7 | -------------------------------------------------------------------------------- /JS/webJS/simpleserve.md: -------------------------------------------------------------------------------- 1 | ## Serving an index.html 2 | 3 | `python -m SimpleHTTPServer` 4 | 5 | - and resets on change -------------------------------------------------------------------------------- /JS/webJS/DOMShadow.md: -------------------------------------------------------------------------------- 1 | # Shadow DOM 2 | 3 | Lets you create a isolated DOM within a thingy. Similar to an iframe 4 | 5 | -------------------------------------------------------------------------------- /JS/All/Electron/packages/README.md: -------------------------------------------------------------------------------- 1 | # Electron Packages 2 | 3 | Cool ones to check out 4 | 5 | - [devtron](https://www.electronjs.org/devtron) -------------------------------------------------------------------------------- /React/All/Gatsby/transformer.md: -------------------------------------------------------------------------------- 1 | # Transformer 2 | 3 | Use transformer plugins to transform raw content brought by data source plugins 4 | 5 | -------------------------------------------------------------------------------- /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/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/Php/Hack.md: -------------------------------------------------------------------------------- 1 | # Hack 2 | 3 | Typed PHP 4 | 5 | - explicit and verified typing 6 | - async 7 | - better arrays and memoization 8 | - Memoization - per request, can just add -------------------------------------------------------------------------------- /Deployment/Cloud GPUS/paperspace.md: -------------------------------------------------------------------------------- 1 | # Paperspace 2 | 3 | Cloud GPUs that you can spin up and down like a server, saves state for free! 4 | 5 | ssh paperspace@172.83.15.38 6 | 7 | -------------------------------------------------------------------------------- /Deployment/AWS/ACM.md: -------------------------------------------------------------------------------- 1 | # Certificate Manager 2 | 3 | Allows https 4 | 5 | Can take up to 30 minutes 6 | 7 | Cant transfer between zones 8 | 9 | Must be in us-east-1 to use for Cloudfront -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /CSS/cursors.md: -------------------------------------------------------------------------------- 1 | # Cursors 2 | 3 | https://estelle.github.io/cssmastery/other/#slide26 4 | 5 | SO MANY 6 | 7 | ## Click Through 8 | 9 | ```css 10 | Pointer-events: none; 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /Deployment/redis.md: -------------------------------------------------------------------------------- 1 | # Redis 2 | 3 | Inmemory data store and pubsub for ephermal/persistent and distrubuted cache, queue, or pubsub 4 | 5 | Many providers that allow VPC access(cant use in local dev) -------------------------------------------------------------------------------- /Deployment/sockets.md: -------------------------------------------------------------------------------- 1 | # Socket Alternatives 2 | 3 | https://www.pubnub.com 4 | 5 | socket.io-redis 6 | 7 | https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /JS/All/Electron/packages/sentry.md: -------------------------------------------------------------------------------- 1 | # Sentry 2 | 3 | ```js 4 | import * as Sentry from "@sentry/electron"; 5 | 6 | Sentry.init({ 7 | dsn: "https://[hi]@sentry.io/2590109" 8 | }); 9 | ``` 10 | 11 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /React/All/Gatsby/pages.md: -------------------------------------------------------------------------------- 1 | # Pages 2 | 3 | Default looks in `/pages` could also implement `createPages` api and set in `gatsby-node.js` 4 | 5 | ## [Advanced](https://www.gatsbyjs.org/docs/creating-and-modifying-pages/) 6 | 7 | -------------------------------------------------------------------------------- /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/Python/flask/cli.md: -------------------------------------------------------------------------------- 1 | # Flask CLI 2 | 3 | Installing Flask install the `flask` command for bash 4 | 5 | Just run `flask` for a good overview of the commands 6 | 7 | Default gets app.py or wsgi.py 8 | 9 | `export FLASK_ENV=development` -------------------------------------------------------------------------------- /React/Next/packages/mdx.md: -------------------------------------------------------------------------------- 1 | ## [MDX Enchanced](https://github.com/hashicorp/next-mdx-enhanced) 2 | 3 | ``` 4 | yarn next-mdx-enhanced 5 | ``` 6 | 7 | # Mdx 8 | 9 | ```bash 10 | yarn -D @next/mdx @mdx-js/loader 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /React/data_loading/README.md: -------------------------------------------------------------------------------- 1 | # How to fetch Data 2 | 3 | - Recommended: React Query 4 | 5 | - useSWR, simple 6 | 7 | GraphQL Options: 8 | 9 | - Apollo Client, og 10 | - Relay, fb mostly 11 | 12 | Other 13 | 14 | - RTK Query -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /JS/packages/lodash.md: -------------------------------------------------------------------------------- 1 | # Lodash 2 | 3 | ```javascript 4 | import _ from 'lodash'; 5 | ``` 6 | 7 | - .isEmpty(x) => works for object, collection, map, or set. 8 | 9 | - .isEqual(a, b).=> does deep compare between everything from arrays and objects to strings -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /JS/All/Node/env.md: -------------------------------------------------------------------------------- 1 | # Env 2 | 3 | See packages/dotenv 4 | 5 | Node.js 20 adds support for .env. files 6 | 7 | ```bash 8 | node --env-file=.env app.js 9 | ``` 10 | 11 | then in code 12 | 13 | ```js 14 | process.env.PORT; // "3000" 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /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/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 -------------------------------------------------------------------------------- /ML/NLP/Overview.md: -------------------------------------------------------------------------------- 1 | # Unstructured Data 2 | No delimiters or rows in raw file 3 | 4 | 1) Raw Text 5 | 2) Tokenize - tell model what to look at 6 | 3) Clean text - remove stop words/ punctuation, stemming 7 | 4) Convert to numeric form 8 | 5) ML alf - fit train 9 | -------------------------------------------------------------------------------- /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/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/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/Python/packages/pillow.md: -------------------------------------------------------------------------------- 1 | # PIL 2 | 3 | Python Image Library 4 | 5 | ```python 6 | from PIL import Image 7 | import requests 8 | from io import BytesIO 9 | 10 | response = requests.get(url) 11 | img = Image.open(BytesIO(response.content)) 12 | ``` 13 | 14 | -------------------------------------------------------------------------------- /Deployment/speed_opt.md: -------------------------------------------------------------------------------- 1 | # Speed Optimizations 2 | 3 | https://gtmetrix.com/ 4 | 5 | Compress with gzip ([express](https://www.npmjs.com/package/compression)) or use a CDN like cloudflare 6 | 7 | Speed performance test available in chrome and https://gtmetrix.com/ 8 | 9 | -------------------------------------------------------------------------------- /JS/All/Chrome_Plugins/url_match.md: -------------------------------------------------------------------------------- 1 | # Match Patterns 2 | 3 | ``` 4 | := :// 5 | := '*' | 'http' | 'https' | 'file' | 'ftp' 6 | := '*' | '*.' + 7 | := '/' 8 | ``` 9 | 10 | -------------------------------------------------------------------------------- /ML/Deploy/Beam.md: -------------------------------------------------------------------------------- 1 | # Beam Cloud 2 | 3 | https://docs.beam.cloud/getting-started/quickstart 4 | 5 | ```bash 6 | curl https://raw.githubusercontent.com/slai-labs/get-beam/main/get-beam.sh -sSfL | sh 7 | beam configure 8 | 9 | pip install beam-sdk 10 | ``` 11 | 12 | -------------------------------------------------------------------------------- /JS/All/Electron/image.md: -------------------------------------------------------------------------------- 1 | # Images 2 | 3 | In Electron, for the APIs that take images, you can pass either file paths or `NativeImage` instances. 4 | 5 | ### Native Images 6 | 7 | ```javascript 8 | 9 | ``` 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /React/packages/shadcn.md: -------------------------------------------------------------------------------- 1 | # ShadCn 2 | 3 | The cool new component library, that lets you copy paste into you app 4 | 5 | ### Init 6 | 7 | ``` 8 | npx shadcn-ui@latest init 9 | ``` 10 | 11 | ### Add 12 | 13 | ``` 14 | npx shadcn-ui@latest add button 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /JS/typescript/enum.md: -------------------------------------------------------------------------------- 1 | # Enum 2 | 3 | ```typescript 4 | enum ModuleState { 5 | VIDEO_1, 6 | QUESTION_1, 7 | VIDEO_2, 8 | QUESTION_2, 9 | } 10 | 11 | const [moduleState, setModuleState] = useState( 12 | ModuleState.VIDEO_1 13 | ); 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Deployment/GCP/README.md: -------------------------------------------------------------------------------- 1 | # Google Cloud Platform 2 | 3 | ### Compare to AWS 4 | 5 | - Better UI/UX, but less polished/buggy interface 6 | - [Always free tier of most things](https://cloud.google.com/free) 7 | - 1 Micro Instance & 1 App Engine 8 | - 5GB of Cloud Storage 9 | - NoSQL DB -------------------------------------------------------------------------------- /JS/bundlers/vite.md: -------------------------------------------------------------------------------- 1 | # [Vite](https://vitejs.dev) 2 | 3 | - Uses esbuild so fasttt 4 | - Better Hot Reloading, uses ESM base dev server which means something like doesnt need to rebundle entire app just part that changed 5 | 6 | ```bash 7 | npm create vite@latest 8 | ``` 9 | 10 | -------------------------------------------------------------------------------- /All/Python/advanced.md: -------------------------------------------------------------------------------- 1 | # Advanced Stuff 2 | 3 | - `globals()` *always* returns the dictionary of the *module* namespace 4 | - `locals()` *always* returns *a* dictionary of the *current* namespace 5 | 6 | print(locals()) will let you do some easy debugging (in fts, extra stuff in global namespace) -------------------------------------------------------------------------------- /Deployment/AWS/EC2/README.md: -------------------------------------------------------------------------------- 1 | # EC2 2 | 3 | Elastic 4 | 5 | Use elastic IP to stop yourself from changing 6 | 7 | If you have to install boilerplate like Docker and such, you can do so on an EC2 instance. Then create an AMI from an existing EC2 that you can use for future things or future scaling. -------------------------------------------------------------------------------- /All/HTML/scripts.md: -------------------------------------------------------------------------------- 1 | # Scripts 2 | 3 | ### defer 4 | 5 | wait to load script until DOM finishes loading, only for external scripts 6 | 7 | ```js 8 | 9 | ``` 10 | 11 | You should defer loading all CSS files that are blocking the rendering of your page. -------------------------------------------------------------------------------- /Deployment/AWS/Storage/Autoscaling.md: -------------------------------------------------------------------------------- 1 | # Autoscaling 2 | 3 | Can have autoscaling EC2 react to cloud watch 4 | 5 | ## Creation 6 | 7 | Make a launch configuration 8 | 9 | Autoscaling group: 10 | 11 | 2) Configure scaling policies: when to scale and min and max 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /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/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/Python/flask/postgres/README.md: -------------------------------------------------------------------------------- 1 | # Postgres in Flask 2 | 3 | ```bash 4 | pip install sqlalchemy psycopg2 Flask-Migrate Flask-SQLAlchemy 5 | ``` 6 | 7 | Recommended packages to use to manage a postgres connection: 8 | 9 | - flask-migrate to manage db updates 10 | - Flask-SQLAlchemy to add some 11 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /JS/packages/node-sass.md: -------------------------------------------------------------------------------- 1 | # Use to compile SCSS 2 | 3 | Works automatically with create-react-act to allow importing of scss 4 | 5 | ```bash 6 | npm install node-sass --save-dev 7 | ``` 8 | 9 | ## Usage 10 | 11 | ```bash 12 | node-sass src/style.scss dest/style.css 13 | node-sass -w src -o dest 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /typora.md: -------------------------------------------------------------------------------- 1 | # Typora Shortcuts 2 | 3 | | Command | Effect | 4 | | ----------- | ------------------------ | 5 | | Cmd-Opt-T | Create Table | 6 | | Cmd-Shift-L | Toggle Left Sidebar | 7 | | Cmd-Shift-O | Search by filename | 8 | | Cmd-Shift-F | Search all files by text | 9 | 10 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /JS/All/Electron/dialog.md: -------------------------------------------------------------------------------- 1 | # Dialog 2 | 3 | Show blocking native messages 4 | 5 | ```js 6 | const indexOfClickedButton = dialog.showMessageBoxSync({ 7 | type: "warning", 8 | message: "Welcome to the future", 9 | title: "Permissions Error" 10 | }); 11 | console.log("Printed after the message is accepted") 12 | ``` 13 | 14 | -------------------------------------------------------------------------------- /JS/packages/concurrently.md: -------------------------------------------------------------------------------- 1 | # Concurrently 2 | 3 | Run two CLI commands at the same time! 4 | 5 | ```bash 6 | npm i concurrently --save-dev 7 | ``` 8 | 9 | ## Usage 10 | 11 | ```json 12 | "scripts": { 13 | "dev": "concurrently \"cd moderator-dashboard && npm run dev\" \"cd main-server && npm run dev\"" 14 | }, 15 | ``` 16 | -------------------------------------------------------------------------------- /Deployment/AWS/Cloudwatch.md: -------------------------------------------------------------------------------- 1 | # Cloudwatch 2 | 3 | Combine data from many sources e.g microservices 4 | 5 | Alarm and stats 6 | 7 | If CPU usage too high, then spin up new EC2 8 | 9 | Create custom metrics 10 | 11 | Log management 12 | 13 | Free tier includes a good amount of logs, dashboards, and metrics don't be too afraid to use very worth -------------------------------------------------------------------------------- /JS/All/Chrome_Plugins/deploying.md: -------------------------------------------------------------------------------- 1 | # Deploying 2 | 3 | https://developer.chrome.com/webstore/publish 4 | 5 | 1) Go to https://chrome.google.com/webstore/developer/dashboard 6 | 7 | 2) Upload zipped folder of Chrome Plugin with manifest.json in root 8 | 9 | 3) If you need the oauth extension key, then you can find it in the url of the submission draft -------------------------------------------------------------------------------- /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/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/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/Python/flask/packages/cors.md: -------------------------------------------------------------------------------- 1 | # Cors 2 | 3 | ```bash 4 | pip install flask-cors 5 | ``` 6 | 7 | ## Flask-cors 8 | 9 | ```python 10 | from flask import Flask 11 | from flask_cors import CORS 12 | 13 | app = Flask(__name__) 14 | CORS(app) 15 | 16 | @app.route("/") 17 | def helloWorld(): 18 | return "Hello, cross-origin-world!" 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /JS/All/Electron/multiplatform.md: -------------------------------------------------------------------------------- 1 | # Differences Between Platforms 2 | 3 | ## Mac 4 | 5 | Icon in taskbar is application icon(.ico or .icns) 6 | 7 | ## Linux 8 | 9 | Icon is taskbar is window icon 10 | 11 | ```js 12 | mainWindow = new BrowserWindow({ 13 | title: 'ElectronApp', 14 | icon: __dirname + '/app/assets/img/icon.png', 15 | }); 16 | ``` -------------------------------------------------------------------------------- /React/All/React_Native/Expo/env.md: -------------------------------------------------------------------------------- 1 | # [Env](https://docs.expo.dev/guides/environment-variables/) 2 | 3 | The Expo CLI will automatically load environment variables with an `EXPO_PUBLIC_` prefix from **.env** files for use 4 | 5 | .env 6 | 7 | ```bash 8 | EXPO_PUBLIC_API_URL=https://staging.example.com 9 | EXPO_PUBLIC_API_KEY=abc123 10 | ``` 11 | 12 | -------------------------------------------------------------------------------- /All/Python/random.md: -------------------------------------------------------------------------------- 1 | # Random 2 | 3 | ```python 4 | import random 5 | random.randint(a, b) 6 | ``` 7 | 8 | 9 | 10 | Return a random integer *N* such that a <= N <= b 11 | 12 | ### Random between 2 floats 13 | 14 | ```python 15 | random.uniform(1.5, 1.9) 16 | ``` 17 | 18 | 1.8733202628557872 19 | 20 | `round(number, ndigits)` - #rounds floating pt to n digits -------------------------------------------------------------------------------- /Deployment/GCP/Network.md: -------------------------------------------------------------------------------- 1 | # Network 2 | 3 | When creating compute add a tag: 4 | 5 | Under the **Firewall** section, expand **Management, security, disks, networking, sole tenancy**, select the **Networking** tab, and enter `postgres-tutorial` for the **Network tags** field. 6 | 7 | Then in VPC network > Firewall you can add rules to all everyone to access by using that tag -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /JS/packages/query-string.md: -------------------------------------------------------------------------------- 1 | # Query-string 2 | 3 | ```js 4 | import queryString from 'query-string' 5 | 6 | //.......(props) { 7 | const vals = queryString.parse(props.location.search); 8 | // "?filter=top&origin=im" 9 | console.log(vals.filter); // "top" 10 | console.log(vals.origin); // "im" 11 | 12 | const stringified = queryString.stringify(vals); 13 | ``` 14 | 15 | -------------------------------------------------------------------------------- /React/All/React_Native/orientation.md: -------------------------------------------------------------------------------- 1 | # Orientation 2 | 3 | ```ts 4 | import * as ScreenOrientation from 'expo-screen-orientation'; 5 | 6 | //... 7 | useEffect(() => { 8 | //lock screen orientation to portrait 9 | (async () => { 10 | await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT); 11 | })(); 12 | }, []); 13 | ``` 14 | 15 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /JS/All/Chrome_Plugins/browser_action.md: -------------------------------------------------------------------------------- 1 | # Browser Action 2 | 3 | *Untested in Manifest V3* 4 | 5 | ```js 6 | await browser.action.setBadgeBackgroundColor({ 7 | color: "#000000" 8 | }); 9 | 10 | await browser.browserAction.setBadgeText({ 11 | text: number.toString() 12 | }); 13 | ``` 14 | 15 | If badge text set to "", then the badge completely disappears regardless of teh badge color -------------------------------------------------------------------------------- /JS/All/Electron/renderer.md: -------------------------------------------------------------------------------- 1 | # Renderer Process 2 | 3 | Access remote 4 | 5 | ```js 6 | const { dialog } = require('electron').remote 7 | console.log(dialog); 8 | ``` 9 | 10 | Make file that works in both 11 | 12 | ```js 13 | const electron = require("electron"); 14 | const dialog = electron.dialog || electron.remote.dialog; //ensure works in both main and renderer 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /JS/timeout.md: -------------------------------------------------------------------------------- 1 | # Timeout 2 | 3 | ```javascript 4 | if(this.timerID !== undefined) { 5 | clearTimeout(this.timerID); 6 | } 7 | this.timerID = setTimeout(this.sendPayload, 4000); 8 | ``` 9 | 10 | ## Interval 11 | 12 | ```js 13 | if(this.timerID !== undefined) { 14 | clearInterval(intervalID); 15 | } 16 | const intervalID = setInterval(() => alert("Hello"), 3000); 17 | 18 | ``` 19 | 20 | -------------------------------------------------------------------------------- /All/Scala/packages.md: -------------------------------------------------------------------------------- 1 | # Packages 2 | 3 | Place class inside package using package clause at top of source 4 | 5 | ```scala 6 | package progfun.examples 7 | 8 | object Hello { 9 | //... 10 | } 11 | ``` 12 | 13 | Another file:˜ 14 | 15 | ```scala 16 | progfun.examples.Hello 17 | //OR 18 | import progfun.examples.Hello 19 | import progfun.examples._ 20 | 21 | Hello 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /Deployment/AWS/Codepipeline.md: -------------------------------------------------------------------------------- 1 | # Code Pipeline 2 | 3 | Has Input Layer (github, S3) 4 | 5 | Has Build Layer (CodeBuild) 6 | 7 | Has Deploy Layer (EBS, CodeDeploy) 8 | 9 | Each Layer is defined in terms of inputs and outputs which are overriden from the defaults 10 | 11 | ## Notifications 12 | 13 | In Cloudwatch Events, can listen for changes to code pipeline status and send notifications -------------------------------------------------------------------------------- /JS/All/Node/packages/dotenv.md: -------------------------------------------------------------------------------- 1 | # Dotenv 2 | 3 | Load .env files into your process.env 4 | 5 | ```bash 6 | npm i dotenv 7 | ``` 8 | 9 | ## Usage 10 | 11 | As early as possible, 12 | 13 | ```js 14 | require('dotenv').config() 15 | ``` 16 | 17 | or 18 | 19 | ```js 20 | import 'dotenv/config' 21 | ``` 22 | 23 | That's it. `process.env` now has the keys and values you defined in your `.env` file 24 | -------------------------------------------------------------------------------- /All/Python/packages/excel.md: -------------------------------------------------------------------------------- 1 | # Excel 2 | 3 | Read with pandas 4 | 5 | ## Throw Pandas DF into Excel File 6 | 7 | `pip install XlsxWriter` 8 | 9 | ```python 10 | 11 | # Specify a writer 12 | writer = pd.ExcelWriter('example.xlsx', engine='xlsxwriter') 13 | 14 | # Write your DataFrame to a file 15 | yourData.to_excel(writer, 'Sheet1') 16 | 17 | # Save the result 18 | writer.save() 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /All/Python/Django/db.md: -------------------------------------------------------------------------------- 1 | # Databases 2 | 3 | Default is sqlite3 because it comes with python, but can use postgres and more 4 | 5 | Default installed apps require a db and migrations 6 | 7 | See setup.md for setup instructions 8 | 9 | ```bash 10 | poetry run python manage.py sqlmigrate polls 0001 #to see what SQL will run 11 | poetry run python manage.py check #check for db errors 12 | ``` 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /JS/packages/cheerio.md: -------------------------------------------------------------------------------- 1 | # [Cheerio](https://cheerio.js.org/) 2 | 3 | Parsing and manipulating HTML and XML. 4 | 5 | ```bash 6 | npm install cheerio 7 | ``` 8 | 9 | ## Usage 10 | 11 | ```ts 12 | const $ = cheerio.load(reviewHtml) 13 | const hiddenText = $('span[style="display:none"]') 14 | .html() 15 | .replace(//g, '\n') 16 | .replace(/<[^>]*>/g, '') 17 | 18 | return hiddenText 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /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/Python/collections/set.md: -------------------------------------------------------------------------------- 1 | # Set 2 | 3 | ```python 4 | new_set = set() 5 | tags_set = {"apple", "banana", "cherry"} 6 | 7 | thisset.remove("banana") 8 | thisset.add("orange") 9 | 10 | z = x.intersection(y) 11 | set3 = set1.union(set2) 12 | ``` 13 | 14 | 15 | 16 | ```ts 17 | const uniqueContactOwners = new Set(); 18 | 19 | for (let uid in uniqueContactOwners) { 20 | //....... 21 | } 22 | 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /React/packages/fluxible.md: -------------------------------------------------------------------------------- 1 | # Fluxible 2 | 3 | A less popular version of redux made by Yahoo, remember flux is a design pattern and fluxible and redux are implementations 4 | 5 | ## Connect to Stores 6 | 7 | ```jsx 8 | Component = connectToStores(Component, [FooStore, BarStore], (context, props) => ({ 9 | foo: context.getStore(FooStore).getFoo(), 10 | bar: context.getStore(BarStore).getBar() 11 | })); 12 | ``` 13 | 14 | -------------------------------------------------------------------------------- /React/All/Gatsby/setup.md: -------------------------------------------------------------------------------- 1 | # Setup 2 | 3 | ```bash 4 | yarn global add gatsby-cli 5 | ``` 6 | 7 | ## Gatsby 8 | 9 | ```bash 10 | gatsby new my-site 11 | gatsby new my-site [starter link] 12 | gatsby new my-site https://github.com/Vagr9K/gatsby-advanced-starter 13 | 14 | cd my-site 15 | gatsby develop 16 | ``` 17 | 18 | ## Basic Usage 19 | 20 | Add a new page to `pages/a.js` and it will be available at `localhost:8000/a` 21 | 22 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /JS/All/Angular/input.md: -------------------------------------------------------------------------------- 1 | ##### input 2 | ```html 3 |
4 | 7 | 8 | 11 |
12 | ``` 13 | 14 | ##### @Input 15 | 16 | Getting input into component 17 | ```ts 18 | @Input() hero: Hero; 19 | ``` 20 | -------------------------------------------------------------------------------- /JS/collections/string.md: -------------------------------------------------------------------------------- 1 | # Strings 2 | 3 | ```js  4 | `String text ${expression}` 5 | ``` 6 | 7 | `"` is the same as `'` 8 | 9 | - `.slice(start, end not included)` 10 | - `.split(" ")` 11 | - `.trim()` //remove whitespace 12 | - `.includes("seq")` - true if "seq" in string 13 | - `.search("W3Schools");` - returns index of first character or -1 14 | - `.toLowerCase()` 15 | - `.toUpperCase()` 16 | - `.join([seperatar ,])` 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /All/Scala/objects.md: -------------------------------------------------------------------------------- 1 | ## Objects 2 | 3 | - Basially singleton class(can have object and class with same name; often for factories) 4 | - Define with `object` instead of `class` and be able to use instantly(can be used within itself) 5 | 6 | ## Companion Object 7 | 8 | Often define companion object with the same name as call 9 | 10 | - can access private members 11 | - like static methods(which uses ClassName.staticmethod() notation) 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /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/Go/testing.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | ```go 4 | import ( 5 | "testing" 6 | 7 | "assistant/knowledge/data/json" 8 | 9 | "github.com/stretchr/testify/assert" 10 | ) 11 | 12 | func TestTransformHerePhoneNumber(t *testing.T) { 13 | rawNumberOnlyNumbers := "6783108763" 14 | res, err := transformHerePhoneNumber(nil, "", rawNumberOnlyNumbers, "", "", nil, nil, nil) 15 | assert.NoError(t, err) 16 | assert.Equal(t, res, "(678)310-8763") 17 | } 18 | ``` 19 | 20 | -------------------------------------------------------------------------------- /JS/All/Node/packages/crypto.md: -------------------------------------------------------------------------------- 1 | # Crypto 2 | 3 | ### Generate Random String 4 | 5 | ```js 6 | var crypto = require("crypto"); 7 | var id = crypto.randomBytes(24).toString('hex'); //byte to hex doubles length, so this will be length 40 8 | ``` 9 | 10 | ## Nanoid 11 | 12 | https://github.com/ai/nanoid 13 | 14 | ```js 15 | const nanoid = require('nanoid') 16 | model.id = nanoid()//=> "V1StGXR8_Z5jdHi6B-myT" 17 | nanoid(10) //=> "IRFa-VaY2b" 18 | ``` 19 | 20 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /JS/All/Angular/bash.md: -------------------------------------------------------------------------------- 1 | # Angular 2 | ## Bash Commands 3 | ```bash 4 | ng new [name] 5 | 6 | ng serve --open 7 | 8 | ng generate component heroes 9 | 10 | ng generate directive|pipe|service|class|guard|interface|enum|module 11 | 12 | ng generate service hero 13 | ng generate service message --module=app 14 | 15 | ng generate module app-routing --flat --module=app 16 | ``` 17 | 18 | `--flat` = don’t put in own folder 19 | 20 | `--module=app` = put in module app 21 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /Deployment/AWS/Lambda.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda (Serverless) 2 | 3 | - run code without provisioning or managing servers 4 | - check out aws toolkit for vscode to more easily connect/test lambda 5 | 6 | Uses: 7 | 8 | - Runs code based on events like S3/DB changes 9 | - ETLs(Extract Transform Load for data analytics) 10 | - Can be used as an API with Amazon API Gateway where you only pay per request (great for small, semi unused projects) 11 | 12 | * See zappa for how to deploy python 13 | -------------------------------------------------------------------------------- /JS/typescript/migration.md: -------------------------------------------------------------------------------- 1 | # Migration 2 | 3 | Use https://github.com/airbnb/ts-migrate 4 | 5 | ``` 6 | npx ts-migrate init . 7 | npx ts-migrate rename . 8 | npx ts-migrate migrate . 9 | npx ts-migrate reignore . 10 | ``` 11 | 12 | 1) Create tsconfig 13 | 14 | 2) Rename files to .js => .ts 15 | 16 | 3) Run ts-migrate plugins 17 | 18 | 4) Add to [webpack](https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html#webpack) 19 | 20 | 5) Reignore? all errors or fix -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /JS/collections/set.md: -------------------------------------------------------------------------------- 1 | # Set 2 | 3 | ```js 4 | const set1 = new Set([1, 2, 3, 4, 5]); 5 | set1.has(1); // expected output: true 6 | set1.add(2); 7 | set1.delete(2); 8 | set1.clear(); 9 | set1.size; 10 | ``` 11 | 12 | ### Convert to Array 13 | 14 | `Array.from(set1)` 15 | 16 | ## Set Operations 17 | 18 | ```js 19 | let union = new Set([...a, ...b]); 20 | let intersection = new Set([...a].filter((x) => b.has(x))); 21 | let difference = new Set([...a].filter((x) => !b.has(x))); 22 | ``` 23 | -------------------------------------------------------------------------------- /React/packages/feather.md: -------------------------------------------------------------------------------- 1 | # React-Feather 2 | 3 | Great React icon Library 4 | 5 | ```bash 6 | npm install react-feather 7 | ``` 8 | 9 | Check out all the icons [here](https://bit.dev/feathericons/react-feather) 10 | 11 | ```jsx 12 | import React from 'react'; 13 | import { Camera } from 'react-feather'; 14 | 15 | const App = () => { 16 | return ; 17 | }; 18 | 19 | export default App; 20 | ``` 21 | 22 | ### Favorite Icons 23 | 24 | Camera | Check | X -------------------------------------------------------------------------------- /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/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 | ![SQL INNER JOIN](https://www.w3schools.com/sql/img_innerjoin.gif) ![SQL LEFT JOIN](https://www.w3schools.com/sql/img_leftjoin.gif) ![SQL RIGHT JOIN](https://www.w3schools.com/sql/img_rightjoin.gif) ![SQL FULL OUTER JOIN](https://www.w3schools.com/sql/img_fulljoin.gif) 6 | 7 | -------------------------------------------------------------------------------- /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/Python/packages/pydub.md: -------------------------------------------------------------------------------- 1 | # Pydub 2 | 3 | Manipulate Audio 4 | 5 | ## Split 6 | 7 | ```python 8 | from pydub import AudioSegment 9 | sound = AudioSegment.from_file("./Community.mp3") 10 | 11 | halfway_point = len(sound) // 2 12 | print(len(sound)) 13 | first_half = sound[:halfway_point] 14 | 15 | # create a new file "first_half.mp3": 16 | first_half.export("./Com.mp3", format="mp3") 17 | ``` 18 | 19 | ## Access Raw Data 20 | 21 | ```python 22 | AudioSegment(...).raw_data 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /Deployment/surge.md: -------------------------------------------------------------------------------- 1 | # {Surge 2 | 3 | For fully static sites, HTML, CSS, SJ 4 | 5 | ```bash 6 | npm install --global surge 7 | 8 | # Then create a (free) account with them 9 | surge 10 | 11 | surge --help 12 | 13 | surge #need domain to relaunch in domain 14 | ``` 15 | 16 | ## React Router 17 | 18 | For react router, you need it to always go to the index.html page, simply change the name of the index.html page to `200.html` and it will route every successful request there 19 | 20 | -------------------------------------------------------------------------------- /React/All/Gatsby/link.md: -------------------------------------------------------------------------------- 1 | # Link 2 | 3 | ```js 4 | import { Link } from "gatsby" 5 | 6 | Home 7 | ``` 8 | 9 | ## Longer Version 10 | 11 | ```js 12 | import { Link } from "gatsby" 13 | 14 | export default () => ( 15 |
16 | Contact 17 |
18 |

What a world.

19 | 20 |
21 | ) 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /CSS/placement/columns.md: -------------------------------------------------------------------------------- 1 | ## Columns 2 | 3 | ```css 4 | column-count: 6; 5 | column-width: 5em; 6 | column-rule: 1px solid #bbb; 7 | column-gap: 2em; 8 | ``` 9 | 10 | - Max column count and min column width 11 | - If words are too long, then colun gap won't work 12 | - column rule is line between columns 13 | 14 | ## Put Header 15 | 16 | ```css 17 | #content { Columns: 8em 3; } 18 | h1 {column-span: all;} 19 | ``` 20 | 21 | At least 8 em, but not more than 3 cols 22 | 23 | A h1 will span all the columns -------------------------------------------------------------------------------- /Deployment/cloudflare.md: -------------------------------------------------------------------------------- 1 | # Cloudflare 2 | 3 | Becomes your DNS provider and adds a cache layer in front of your server 4 | 5 | Allows you to CNAME a root domain 6 | 7 | FREE SSL & FREE CACHING WTF 8 | 9 | Very helpful support articles and UI 10 | 11 | 1) Add DNS Records 12 | 13 | 2) Go to ssl/tls and edge certificates to enable 14 | 15 | ### Redirect non-www to www 16 | 17 | Need record for both non-www and www 18 | 19 | Add pagerule that redirect `example.com*` to `https://www.example.com/$1` 20 | 21 | -------------------------------------------------------------------------------- /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/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/Scala/exceptions.md: -------------------------------------------------------------------------------- 1 | # Exceptions 2 | 3 | ```scala 4 | def error(msg: String) = throw new Error(msg) 5 | // (msg: String) => Nothing 6 | throw Exc 7 | 8 | ``` 9 | 10 | ## Try Catch 11 | 12 | ```scala 13 | //val result: Int = //an expression so can do this 14 | try { 15 | remoteCalculatorService.add(1, 2) 16 | } catch { 17 | case e: ServerIsDownException => log.error(e, "the remote calculator service is unavailable. should have kept your trusty HP.") 18 | } finally { 19 | remoteCalculatorService.close() 20 | } 21 | ``` 22 | -------------------------------------------------------------------------------- /All/Python/collections/dict.md: -------------------------------------------------------------------------------- 1 | # Dictionaries 2 | 3 | ```python 4 | d= {} 5 | d[k] = v 6 | del d[k] 7 | # Will error if doesn't exist 8 | d["key"] 9 | d.get('key', 'defaultValue') 10 | d.pop(k, None) #get and pop, allows you to remove without checking for existence 11 | ``` 12 | 13 | ### Iteration 14 | 15 | ```python 16 | #For Python 2.x 17 | for key, value in d.iteritems(): 18 | 19 | #For Python 3.x: 20 | for k, v in d.items(): 21 | for v in d.values(): 22 | for k in d.keys(): 23 | 24 | lambda x: x.values()[0] 25 | ``` 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /All/Python/flask/flash.md: -------------------------------------------------------------------------------- 1 | # Flash 2 | 3 | .py 4 | 5 | ```python 6 | from flask import flash 7 | 8 | @app.route('/login', methods=['GET', 'POST']) 9 | def login(): 10 | #... 11 | flash('You were successfully logged in') 12 | ``` 13 | 14 | .html 15 | 16 | ```jinja2 17 | {% with messages = get_flashed_messages() %} 18 | {% if messages %} 19 |
    20 | {% for message in messages %} 21 |
  • {{ message }}
  • 22 | {% endfor %} 23 |
24 | {% endif %} 25 | {% endwith %} 26 | ``` 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /JS/bundlers/parcel.md: -------------------------------------------------------------------------------- 1 | # Parcel 2 | 3 | Bundling without configuration 4 | 5 | ```bash 6 | npm i parcel 7 | ``` 8 | 9 | 10 | 11 | Simple building 12 | 13 | ```json 14 | "scripts": { 15 | "build": "parcel build src/js/main.js -d src/build/ -o main.js", 16 | "watch": "parcel watch src/js/main.js -d src/build/ -o main.js", 17 | ``` 18 | 19 | If using inside a chrome plugin, use` --no-hmr` flag to not do hot module replacement b/c you cant so will have error 20 | 21 | ## Debugging 22 | 23 | ``` 24 | rm -rf .parcel-cache 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /JS/packages/csv-parser.md: -------------------------------------------------------------------------------- 1 | # Csv 2 | 3 | ```sh 4 | npm i -s csv-parser 5 | ``` 6 | 7 | Then, lets put the CSV data from the beginning of the article to a file called "data.csv" and follow up with a very simple example: 8 | 9 | ```javascript 10 | const csv = require('csv-parser'); 11 | const fs = require('fs'); 12 | 13 | fs.createReadStream('data.csv') 14 | .pipe(csv()) 15 | .on('data', (row) => { 16 | console.log(row); 17 | }) 18 | .on('end', () => { 19 | console.log('CSV file successfully processed'); 20 | }); 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /JS/webJS/packages/videojs.md: -------------------------------------------------------------------------------- 1 | # Videojs 2 | 3 | ```bash 4 | yarn add video.js 5 | ``` 6 | 7 | ## Usage 8 | 9 | Just on top of video html player 10 | 11 | ```html 12 | 16 | ``` 17 | 18 | ```html 19 | 20 | 21 | 22 | 23 | ``` -------------------------------------------------------------------------------- /Deployment/AWS/Docker.md: -------------------------------------------------------------------------------- 1 | # Docker in AWS 2 | 3 | ## EC2 4 | 5 | Instance should be Linux 2 or AMI 6 | 7 | ```bash 8 | sudo yum update -y 9 | 10 | # Linux 2 11 | sudo amazon-linux-extras install docker 12 | #OR Linux 13 | sudo yum install docker 14 | 15 | sudo service docker start 16 | #Adds ec2-user to the docker group to use docker w/out sudo. Need to relog 17 | sudo usermod -a -G docker ec2-user 18 | ``` 19 | 20 | Make sure to expose port 80 and then you can access it through the IP address 21 | 22 | ## See Docker basics for how to use 23 | 24 | -------------------------------------------------------------------------------- /JS/packages/trpc.md: -------------------------------------------------------------------------------- 1 | # Trpc 2 | 3 | Typesafe Remote Procedure Call, Better APIs 4 | 5 | - define a server-side router for your procedures, then export inferred type, then import type client side 6 | - Type errors with your API contracts will be caught at build time 7 | - Arguably server actions and ssc in Next.js solve most of these problems 8 | 9 | ## Usage 10 | 11 | ```ts 12 | // HTTP/REST 13 | const res = await fetch('/api/users/1'); 14 | const user = await res.json(); 15 | // RPC 16 | const user = await api.users.getById({ id: 1 }); 17 | ``` 18 | 19 | -------------------------------------------------------------------------------- /All/Python/crypto.md: -------------------------------------------------------------------------------- 1 | # Secrets 2 | 3 | Python 3.6 and up, default 4 | 5 | used for generating cryptographically strong random numbers suitable for managing data such as passwords, account authentication, security tokens, and related secrets. 6 | 7 | ```python 8 | import secrets 9 | ``` 10 | 11 | ```python 12 | >> secrets.token_hex(nbytes=16) 13 | '17adbcf543e851aa9216acc9d7206b96' 14 | 15 | >>> secrets.token_urlsafe(16) 16 | 'X7NYIolv893DXLunTzeTIQ' 17 | 18 | >>> secrets.token_bytes(128 // 8) 19 | b'\x0b\xdcA\xc0.\x0e\x87\x9b`\x93\\Ev\x1a|u' 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /All/Scala/performance&style.md: -------------------------------------------------------------------------------- 1 | # Performance 2 | 3 | - Prefer Vector over List 4 | - Use a set instead of filtering over everything if you plan on getting more than a couple elements out of a collection. e.g. just because list.filter achieves the same result as set.contains, use a set if appropriate. 5 | - In concurrent programs with a write/read ratio less than 1/10, use an immutable collection and an atomic reference. You get better (and more consistent) performance out of an immutable hash set and an atomic reference for both reads and writes than a ConcurrentHashMap. 6 | 7 | -------------------------------------------------------------------------------- /JS/All/Angular/typescript.md: -------------------------------------------------------------------------------- 1 | ## TypeScript: 2 | 3 | ##### Classes 4 | In a hero.ts file, then import it everywhere you use it 5 | ```ts 6 | export class Hero { 7 | id: number; 8 | name: string; 9 | } 10 | ``` 11 | 12 | ##### Services: 13 | 14 | `providers: [HeroService]` in app.module.ts 15 | 16 | ```ts 17 | constructor(private heroService: HeroService) { 18 | } 19 | 20 | ngOnInit() { 21 | this.heroes = this.heroService.getHeroes(); 22 | } 23 | ``` 24 | 25 | - In a class, public if you use it in the html or something 26 | - Define getHeroes in the service 27 | -------------------------------------------------------------------------------- /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/Python/flask/packages.md: -------------------------------------------------------------------------------- 1 | ## Notable Packages 2 | 3 | ## Bootstrap 4 | Basically provides macros, I would just use regular bootstrap as fun as abstracting away form creation is 5 | ```py 6 | from flask_bootstrap import Bootstrap 7 | ``` 8 | 9 | ```html 10 | {% extends "bootstrap/base.html" %} 11 | {% block title %}This is an example page{% endblock %} 12 | 13 | {% block navbar %} 14 | 17 | {% endblock %} 18 | 19 | {% block content %} 20 |

Hello, Bootstrap

21 | {% endblock %} 22 | ``` 23 | -------------------------------------------------------------------------------- /Deployment/AWS/IAM.md: -------------------------------------------------------------------------------- 1 | # IAM roles 2 | 3 | IAM roles are a secure way to grant permissions to entities that you trust. Examples of entities include the following: 4 | 5 | - IAM user in another account 6 | - Application code running on an EC2 instance that needs to perform actions on AWS resources 7 | - An AWS service that needs to act on resources in your account to provide its features 8 | - Users from a corporate directory who use identity federation with SAML 9 | 10 | IAM roles issue keys that are valid for short durations, making them a more secure way to grant access. -------------------------------------------------------------------------------- /JS/typescript/generics.md: -------------------------------------------------------------------------------- 1 | # Generics 2 | 3 | A type that takes other types are parameters 4 | 5 | ### Limiting Acceptable Types 6 | 7 | extends on the left limits the types acceptable 8 | 9 | ```typescript 10 | type RecursivePartialBy = Omit & 11 | RecursivePartial>; 12 | ``` 13 | 14 | ### Conditional Typing 15 | 16 | extends on the right can create conditional typing 17 | 18 | ```typescript 19 | type TypeDataPartial = T extends { type_data: unknown } 20 | ? RecursivePartialBy 21 | : T; 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /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/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/Python/packages/passwords.md: -------------------------------------------------------------------------------- 1 | # PassLib 2 | 3 | - Supports many hashing types with simple interface 4 | 5 | `pip install passlib` 6 | 7 | ```python 8 | from passlib.hash import pbkdf2_sha256 9 | 10 | # generate new salt, and hash a password 11 | hash = pbkdf2_sha256.hash("toomanysecrets") 12 | #hash '$pbkdf2-sha256$29000$N2YMIWQsBWBMae09x1jrPQ$1t8iyB2A.WF/Z5JZv.lfCIhXXN33N23OSgQYThBYRfk' 13 | 14 | pbkdf2_sha256.verify("toomanysecrets", hash) 15 | #True 16 | pbkdf2_sha256.verify("joshua", hash) 17 | #False 18 | ``` 19 | 20 | ## Alternatives 21 | 22 | - Werkzeug.security 23 | - Bcrypt 24 | -------------------------------------------------------------------------------- /JS/webJS/keyboard.md: -------------------------------------------------------------------------------- 1 | # Keyboard Input 2 | 3 | There are three types of keyboard events: `keydown`, `keypress`, and `keyup`. For most keys, Gecko dispatches a sequence of key events like this: 4 | 5 | 1. When the key is first pressed, the `keydown` event is sent. 6 | 2. If the key is not a modifier key, the `keypress` event is sent. 7 | 3. When the user releases the key, the `keyup` event is sent. 8 | 9 | | Key | `event.key` | `event.code` | 10 | | :------ | :-------------- | :----------- | 11 | | Z | `z` (lowercase) | `KeyZ` | 12 | | Shift+Z | `Z` (uppercase) | `KeyZ` | -------------------------------------------------------------------------------- /React/All/React_Native/Expo/development_build.md: -------------------------------------------------------------------------------- 1 | # [Development Build](https://docs.expo.dev/develop/development-builds/introduction/) 2 | 3 | Basically like your own version of Expo Go that you install on your device 4 | 5 | In `eas.json`, add development client true and distribution internal 6 | 7 | eas.json 8 | 9 | ```json 10 | { 11 | "build": { 12 | "development": { 13 | "developmentClient": true, 14 | "distribution": "internal" 15 | }, 16 | "preview": { 17 | "distribution": "internal" 18 | }, 19 | "production": {} 20 | } 21 | } 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /React/Next/config.md: -------------------------------------------------------------------------------- 1 | # Next Config 2 | 3 | Create `next.config.js` in root 4 | 5 | ```javascript 6 | // next.config.js 7 | const withMdxEnhanced = require("next-mdx-enhanced"); 8 | 9 | module.exports = withMdxEnhanced({ 10 | layoutPath: "layouts", 11 | defaultLayout: true, 12 | fileExtensions: ["mdx"], 13 | remarkPlugins: [], 14 | rehypePlugins: [], 15 | extendFrontMatter: { 16 | process: (mdxContent, frontMatter) => {}, 17 | phase: "prebuild|loader|both", 18 | }, 19 | })({ 20 | pageExtensions: ["js", "jsx", "md", "mdx", "ts", "tsx"], 21 | }); 22 | 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /mac.md: -------------------------------------------------------------------------------- 1 | # General Mac Shortcuts 2 | 3 | ## Finder 4 | 5 | | Cmd | effect | 6 | | --------------- | ------------------------------- | 7 | | Command+Shift+G | Go to Any Folder by Path | 8 | | Command+Shift+5 | Record Entire Screen/Screenshot | 9 | | | | 10 | 11 | You can add custom shortcut to any applications Menu Items 12 | 13 | - go to keyboard/shortcuts/App Shortcuts 14 | - Click Plus and put the exact menu title with the custom command 15 | - It will override other app shortcuts so b careful 16 | -------------------------------------------------------------------------------- /React/packages/general.md: -------------------------------------------------------------------------------- 1 | # General 2 | 3 | - [React Loaders] - https://jonjaques.github.io/react-loaders/ 4 | 5 | - ```bash 6 | npm i --save react-loaders loaders.css 7 | ``` 8 | 9 | ```js 10 | import Loader from 'react-loaders'; 11 | let loader = ; 12 | ``` 13 | 14 | - ```css 15 | $primary-color: $my-brand-color; 16 | @import 'loaders.css/src/animations/ball-pulse.scss' 17 | 18 | .loader-hidden { 19 | display: none; 20 | } 21 | .loader-active { 22 | display: block; 23 | } 24 | ``` 25 | 26 | - -------------------------------------------------------------------------------- /React/Next/setup.md: -------------------------------------------------------------------------------- 1 | # Setup 2 | 3 | ```bash 4 | npx create-next-app@latest 5 | ``` 6 | 7 | ## Usage 8 | 9 | ```bash 10 | yarn dev 11 | ``` 12 | 13 | ## Absolute Path Imports 14 | 15 | ### TS 16 | 17 | ```json 18 | "compilerOptions": { 19 | "baseUrl": ".", 20 | "paths": { 21 | "conf": ["conf/*"], 22 | "src": ["src/*"], 23 | "styles": ["styles/*"] 24 | }, 25 | ... 26 | ``` 27 | 28 | ### JS 29 | 30 | Jsconfig.json 31 | 32 | ```js 33 | { 34 | "compilerOptions": { 35 | "paths": { 36 | "src": ["src"] 37 | } 38 | } 39 | } 40 | ``` 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /All/Python/packages/dotenv.md: -------------------------------------------------------------------------------- 1 | # Environment Variables 2 | 3 | ```bash 4 | pip install python-dotenv 5 | ``` 6 | 7 | `python-dotenv` reads key-value pairs from a `.env` file and sets them as environment variables 8 | 9 | .env (git ignore this) 10 | 11 | ``` 12 | CONFIG_PATH=${HOME}/.config/foo 13 | DOMAIN=example.org 14 | EMAIL=admin@${DOMAIN} 15 | ``` 16 | 17 | script.py 18 | 19 | ```python 20 | from dotenv import load_dotenv 21 | import os 22 | 23 | load_dotenv() 24 | 25 | SECRET_KEY = os.getenv("EMAIL") 26 | DATABASE_PASSWORD = os.getenv("DATABASE_PASSWORD") 27 | ``` 28 | 29 | flask run auto does this -------------------------------------------------------------------------------- /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, "

Hello from Go

")//print to writer object 21 | } 22 | ``` 23 | 24 | #### Usage 25 | 26 | ```go 27 | func main() { 28 | var h Hello 29 | err := http.ListenAndServe("localhost:4000", h) 30 | checkError(err) 31 | } 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /React/packages/intersection-observer.md: -------------------------------------------------------------------------------- 1 | # [Intersection Observer](https://github.com/thebuilder/react-intersection-observer) 2 | 3 | ```bash 4 | yarn add react-intersection-observer 5 | ``` 6 | 7 | ## Usage 8 | 9 | ```tsx 10 | import React from 'react'; 11 | import { useInView } from 'react-intersection-observer'; 12 | 13 | const Component = () => { 14 | const { ref, inView, entry } = useInView({ 15 | /* Optional options */ 16 | threshold: 0, 17 | }); 18 | 19 | return ( 20 |
21 |

{`Header inside viewport ${inView}.`}

22 |
23 | ); 24 | } 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /Deployment/Cloud GPUS/replicate.md: -------------------------------------------------------------------------------- 1 | # Replicate 2 | 3 | ```shell 4 | pip install replicate 5 | ``` 6 | 7 | Next, [copy your API token](https://replicate.com/account) and authenticate by setting it as an environment variable: 8 | 9 | ```console 10 | export REPLICATE_API_TOKEN=[token] 11 | ``` 12 | 13 | Then, run the model: 14 | 15 | ```python 16 | import replicate 17 | output = replicate.run( 18 | "devxpy/cog-wav2lip:8d65e3f4f4298520e079198b493c25adfc43c058ffec924f2aefc8010ed25eef", 19 | input={"face": open("path/to/file", "rb")} 20 | ) 21 | print(output) 22 | ``` 23 | 24 | ### Nodejs 25 | 26 | ``` 27 | ``` 28 | 29 | -------------------------------------------------------------------------------- /Deployment/GCP/Compute.md: -------------------------------------------------------------------------------- 1 | # Compute 2 | 3 | [Setup Postgres on Compute](https://cloud.google.com/community/tutorials/setting-up-postgres) 4 | 5 | 1. In the Cloud Console, go to the [**VM instances**](https://console.cloud.google.com/compute/instances) page. 6 | 2. Click **Create**. 7 | 3. Use General Purpose > N1 > f1-micro 8 | 4. In the **Public images** tab, choose **Ubuntu** for **Operating system**. 9 | 5. In the **Version** dropdown list, choose **Ubuntu 20.04 LTS**. 10 | 6. In the **Boot disk type** section, select **Standard persistent disk**. 11 | 7. Click **Select**. 12 | 8. Click **Create** to create the instance. 13 | 14 | -------------------------------------------------------------------------------- /JS/collections/JSON.md: -------------------------------------------------------------------------------- 1 | # JSON 2 | 3 | COmments not supported 4 | 5 | Must be double quotes 6 | 7 | ```json 8 | { 9 | "telephone": { 10 | "comment": "The phone number associated with this POI.", 11 | "type": "string", 12 | "example": "(415)383-9600" 13 | }, 14 | "timezone": { 15 | "comment": "The IANA timezone this POI is located in.", 16 | "type": "string", 17 | "example": "America/Los_Angeles" 18 | }, 19 | } 20 | ``` 21 | 22 | ## Parsing 23 | 24 | ```js 25 | var obj = JSON.parse('{ "name":"John", "age":30, "city":"New York"}'); 26 | let myJSON = JSON.stringify(obj); 27 | ``` 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /JS/webJS/scroll.md: -------------------------------------------------------------------------------- 1 | # Scroll 2 | 3 | ```typescript 4 | element.scrollIntoView(); 5 | element.scrollIntoView(alignToTop); // Boolean parameter 6 | element.scrollIntoView({ 7 | behavior: "smooth",//auto or smooth 8 | block: "end",//vertical alignement: start, center, end, nearest 9 | inline: "nearest", //horizontal alignement: start, center, end, nearest 10 | }); 11 | ``` 12 | 13 | ## Scroll Into View Moves Entire Page 14 | 15 | ```js 16 | itemR.current.parentElement.scroll({ 17 | top: itemR.current.offsetTop, 18 | behavior: "smooth", 19 | }); 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /React/packages/SWR.md: -------------------------------------------------------------------------------- 1 | # [SWR](https://swr.vercel.app/) 2 | 3 | ### SWR 4 | 5 | - **Fast**, **lightweight** and **reusable** data fetching 6 | - Built-in **cache** and request deduplication 7 | - **Real-time** experience 8 | - Transport and protocol agnostic 9 | - SSR / ISR / SSG support 10 | - TypeScript ready 11 | - React Native 12 | 13 | ```jsx 14 | import useSWR from 'swr' 15 | 16 | function Profile() { 17 | const { data, error } = useSWR('/api/user', fetch) 18 | 19 | if (error) return
failed to load
20 | if (!data) return
loading...
21 | return
hello {data.name}!
22 | } 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /React/packages/color.md: -------------------------------------------------------------------------------- 1 | # Color 2 | 3 | ```bash 4 | yarn add react-color 5 | ``` 6 | 7 | ### Usage 8 | 9 | ```react 10 | import React from 'react' 11 | import { SketchPicker } from 'react-color' 12 | 13 | class Component extends React.Component { 14 | 15 | render() { 16 | return 17 | } 18 | } 19 | ``` 20 | 21 | You can import `AlphaPicker` `BlockPicker` `ChromePicker` `CirclePicker` `CompactPicker` `GithubPicker` `HuePicker` `MaterialPicker` `PhotoshopPicker` `SketchPicker` `SliderPicker` `SwatchesPicker` `TwitterPicker` respectively. 22 | 23 | > 100% inline styles via [ReactCSS](http://reactcss.com/) 24 | 25 | -------------------------------------------------------------------------------- /React/All/React_Native/packages/screenshot.md: -------------------------------------------------------------------------------- 1 | # React Native View Shot 2 | 3 | ```bash 4 | npx expo install react-native-view-shot 5 | ``` 6 | 7 | ## Usage 8 | 9 | ```react 10 | function ExampleCaptureOnMountManually { 11 | const ref = useRef(); 12 | 13 | useEffect(() => { 14 | // on mount 15 | ref.current.capture().then(uri => { 16 | console.log("do something with ", uri); 17 | }); 18 | }, []); 19 | 20 | return ( 21 | 22 | ...Something to rasterize... 23 | 24 | ); 25 | } 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /All/Python/collections/fancyDicts.md: -------------------------------------------------------------------------------- 1 | ## OrderedDict 2 | 3 | keeps order of insertion 4 | 5 | ```python 6 | from collections import OrderedDict 7 | ``` 8 | 9 | ## DefaultDict 10 | 11 | Creates default, nonnull value for keys 12 | 13 | ```python 14 | from collections import defaultdict 15 | d = defaultdict(list) 16 | for k, v in somePairs: 17 | d[k].append(v) 18 | ``` 19 | 20 | ## Counter 21 | 22 | Counts elements 23 | 24 | ```python 25 | from collections import Counter 26 | c = Counter("hell") #Counter({'l': 2, 'h': 1, 'e': 1}) 27 | 28 | #Add iterables of values 29 | c.update([1, 3, 4]) 30 | c.most_common(10) # 10 most common 31 | ``` 32 | 33 | -------------------------------------------------------------------------------- /JS/All/Node/setup.md: -------------------------------------------------------------------------------- 1 | # Setup for Nodejs/Express 2 | 3 | `node` will work if you have node 4 | 5 | ## Using Generator 6 | ```bash 7 | npm install express-generator -g 8 | express [project name] --view=ejs 9 | ``` 10 | - `--view=ejs` adds ejs engine support 11 | - `--no-view` 12 | - `--git` adds a gitignore 13 | 14 | ## Running 15 | 16 | Add the following to package.json 17 | 18 | ```json 19 | "scripts": { 20 | "start": "export NODE_ENV=production && node ./bin/www", 21 | "dev": "export NODE_ENV=development && export DEBUG=app* && nodemon ./bin/www" 22 | } 23 | ``` 24 | 25 | Debug is for debug library 26 | 27 | Export works for config library -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /CSS/colors.md: -------------------------------------------------------------------------------- 1 | # Colors 2 | 3 | ```Css 4 | color: white; 5 | color : #fff; 6 | color: #FFFFFF; 7 | color: transparent; 8 | color: currentColor; 9 | color: rgb(255,255,255); 10 | color: rgb(100%,100%,100%); 11 | color: rgba(255,255,255, 1); 12 | color: hsl(0, 100%, 100%) 13 | ``` 14 | 15 | Border defaults to currentColor which is color of text 16 | 17 | Alpha: 0-1 18 | 19 | HSLAddd(Hue, saturation, lightness, and alphatranspency) 20 | 21 | Transparent == rgba(0, 0, 0, 0); 22 | 23 | ## Opacity vs AlphaTransparent 24 | 25 | Alphatransparent just makes text transparent 26 | 27 | Opacity, text element shadow, everything becomes transparent 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /JS/All/Chrome_Plugins/shortcuts.md: -------------------------------------------------------------------------------- 1 | # Shortcuts / Commands 2 | 3 | Listen for key presses and get event in background script 4 | 5 | background listener 6 | 7 | ```js 8 | browser.commands.onCommand.addListener((command) => { 9 | debug("Command:", command); 10 | if (command === "insert-request-link") { 11 | insertRequestLink(); 12 | } 13 | }); 14 | ``` 15 | 16 | manifest.json 17 | 18 | ```json 19 | "commands": { 20 | "start-recording": { 21 | "suggested_key": { 22 | "default": "Ctrl+Shift+E", 23 | "mac": "Command+Shift+E" 24 | }, 25 | "description": "Toggle feature foo" 26 | } 27 | }, 28 | ``` 29 | 30 | -------------------------------------------------------------------------------- /React/All/React_Native/width_height.md: -------------------------------------------------------------------------------- 1 | # Dimensions 2 | 3 | - Unitless in React-Native and represent density-independent pixels 4 | 5 | ```jsx 6 | 7 | 8 | 9 | 10 | 11 | ``` 12 | 13 | ### Width and Height 14 | 15 | Both `width` and `height` can take following values: 16 | 17 | - `auto` => default based on its content 18 | - `pixels` => absolute pixels, could change b/c of other styles 19 | - `percentage` => % of parent -------------------------------------------------------------------------------- /All/HTML/favicon.md: -------------------------------------------------------------------------------- 1 | # Favicon 2 | 3 | ## Finding a urls favicon 4 | 5 | Simplest, google internal service 6 | 7 | https://www.google.com/s2/favicons?domain=www.stackoverflow.com 8 | 9 | [Manual solution](https://stackoverflow.com/questions/5119041/how-can-i-get-a-web-sites-favicon) 10 | 11 | 1. Look for the `favicon.ico` at the root of the domain 12 | 13 | `www.domain.com/favicon.ico` 14 | 15 | 2. Look for a `` tag with the `rel="shortcut icon"` attribute 16 | 17 | `` 18 | 19 | 3. Look for a `` tag with the `rel="icon"` attribute 20 | 21 | `` 22 | 23 | -------------------------------------------------------------------------------- /All/Python/flask/deploying.md: -------------------------------------------------------------------------------- 1 | # Deploying Options 2 | 3 | ## Simplest 4 | 5 | `ngrok http [THE PORT YOU WANT]` 6 | 7 | ## EC2 8 | 9 | To access over docker or AWS, must run flask development server **which should never be used** like this: 10 | 11 | ` app.run(debug=True, host='0.0.0.0')` 12 | 13 | **never do this**: `sudo pipenv run flask run -h 0.0.0.0 -p 80` 14 | 15 | ## Gunicorn 16 | 17 | WSGI(python web server) recommended version 18 | 19 | `gunicorn [OPTIONS] APP_MODULE` 20 | 21 | APP_MODULE means \$(MODULE_NAME):\$(VARIABLE_NAME) 22 | 23 | ## Heroku 24 | 25 | Make `Procfile` in main folder to tell heroku what to do 26 | 27 | Add line 28 | 29 | -------------------------------------------------------------------------------- /JS/All/Electron/packages/electron-log.md: -------------------------------------------------------------------------------- 1 | # Electron-Log 2 | 3 | Log to file in production 4 | 5 | By default, it writes logs to the following locations: 6 | 7 | - **on Linux:** `~/.config/{app name}/logs/{process type}.log` 8 | - **on macOS:** `~/Library/Logs/{app name}/{process type}.log` 9 | - **on Windows:** `%USERPROFILE%\AppData\Roaming\{app name}\logs\{process type}.log` 10 | 11 | ```js 12 | const log = require("electron-log"); 13 | Object.assign(console, log.functions); //replace console with file logging in the main process 14 | ``` 15 | 16 | Supports following log levels 17 | 18 | ``` 19 | error, warn, info, verbose, debug, silly 20 | ``` 21 | 22 | ### -------------------------------------------------------------------------------- /React/All/React_Native/Expo/README.md: -------------------------------------------------------------------------------- 1 | # Expo 2 | 3 | Start a project without Xcode/Android Studio 4 | 5 | Quickly deploy changes to your phone over ngrok, hot reloading 6 | 7 | Expo SDK gives ez access to underlying native APIS 8 | 9 | [Limitations](https://docs.expo.io/versions/latest/introduction/why-not-expo/) => can always eject though 10 | 11 | **Managed** workflow has only JS and Expo does rest 12 | 13 | **Bare** workflow give full control over native project with Expo SDK, *ejection* to regular react native project 14 | 15 | ## Constants 16 | 17 | ```js 18 | import { Platform } from 'react-native'; 19 | 20 | if (Platform.OS !== 'web') 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /React/packages/telephone.md: -------------------------------------------------------------------------------- 1 | # Telephone Input 2 | 3 | [UI Discussion](https://uxmovement.com/forms/bad-practices-on-phone-number-form-fields/) 4 | 5 | ## React Package 6 | 7 | ## Installation 8 | 9 | ``` 10 | npm install react-phone-input-2 --save 11 | ``` 12 | 13 | ## Usage 14 | 15 | - has international code selection, validation, and autoformatting as you would want 16 | 17 | ```javascript 18 | import PhoneInput from 'react-phone-input-2' 19 | import 'react-phone-input-2/lib/style.css' 20 | 21 | const [phone, setPhone] = useState("") 22 | setPhone(phone)} 26 | /> 27 | ``` 28 | 29 | -------------------------------------------------------------------------------- /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/Python/Django/router.md: -------------------------------------------------------------------------------- 1 | # Router 2 | 3 | In the `app/urls.py`, add if it doesn't exist 4 | 5 | ```python 6 | from django.urls import path 7 | 8 | from . import views 9 | 10 | urlpatterns = [ 11 | path('', views.index, name='index'), 12 | path('/results', views.detail, name='detail'), 13 | ] 14 | ``` 15 | 16 | Then in the `project/urls.py`, where polls is the app folder name 17 | 18 | ```python 19 | from django.contrib import admin 20 | from django.urls import include, path 21 | 22 | urlpatterns = [ 23 | path('polls/', include('polls.urls')), #sends remaining url to the includes 24 | path('', admin.site.urls), 25 | ] 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /JS/packages/prettier.md: -------------------------------------------------------------------------------- 1 | # Prettier 2 | 3 | An opinionated code formatter to enforce consistent style on save 4 | 5 | Needs to be configured to work with eslint to get correct code, see eslint for info 6 | 7 | ## Other 8 | 9 | Can set `prettier.require` in settings to only run in Vscode on save 10 | 11 | ## Config 12 | 13 | Use `.prettierrc.yaml` 14 | 15 | ```yaml 16 | trailingComma: "es5" #Trailing commas where valid in ES5 (objects, arrays, etc.) 17 | tabWidth: 2 18 | ``` 19 | 20 | ### Cli 21 | 22 | Use yarn first in your project with prettier installed so you don't have to install globally 23 | 24 | ```bash 25 | yarn prettier write . 26 | ``` 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Deployment/AWS/SQS.md: -------------------------------------------------------------------------------- 1 | # Simple Queue Service 2 | 3 | **See Deployment/Task_Queues for comparing between services, this is just a stub** 4 | 5 | - Simplest to spin up in AWS with free tier offering 1M free messages 6 | - The service must be long **polled** for messages 7 | - Offers high throughput Standard "at least-once-delievery" which requeues a message if it was consumed from the queue and a visibility timeout passes 8 | - Can also do up to 3k message/sec when order important with SQS FIFO "exactly once delivery" 9 | - Base rate of 20k+/sec with more expensive options to request 10 | - Messages must be less than 256KiB in size, but can turn it into S3 object 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /CSS/display.md: -------------------------------------------------------------------------------- 1 | ## Old 2 | 3 | | Value | Effect | 4 | | ------------ | ------------------------------------------------------------ | 5 | | block | Starts on new line, fill width of parent container | 6 | | inline | Remain in line and only take up width of content(height/width have no effect) | 7 | | inline-block | Remain in line, can apply height and width | 8 | | | | 9 | 10 | ## HTML 5 11 | 12 | All elements inline by default 13 | 14 | Div is full width and needed height 15 | 16 | Tables have equal heights 17 | 18 | - -------------------------------------------------------------------------------- /CSS/lists.md: -------------------------------------------------------------------------------- 1 | # Lists 2 | 3 | You can style many parts of the list 4 | 5 | ```css 6 | list-style-image: url('sqpurple.gif'); 7 | list-style-position: inside; //default is outside 8 | ``` 9 | 10 | List also comes with default margin and padding if you want to get rid of it 11 | 12 | ```css 13 | ul { 14 | list-style-type: none; 15 | margin: 0; 16 | padding: 0; 17 | } 18 | ``` 19 | 20 | You can't change the size of the image very well so usually just better to use an actual img tag 21 | 22 | ### Getting that last/first element to be properly spaced 23 | 24 | ```scss 25 | .article-list { 26 | margin-bottom: 1rem; 27 | 28 | &:last-child { 29 | margin-bottom: 0; 30 | } 31 | } 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /CSS/tailwind/typography.md: -------------------------------------------------------------------------------- 1 | # Typography 2 | 3 | Tailwind CSS Typography plugin, https://github.com/tailwindlabs/tailwindcss-typography 4 | 5 | - Tailwind disables the styles, but maybe you want the

and stuff, to work and look nice out of the box 6 | - https://play.tailwindcss.com/uj1vGACRJA?layout=preview 7 | - Just add `prose` class to your container and

,
    , etc will work beautifully 8 | 9 | | `prose-sm` | 0.875rem *(14px)* | 10 | | ------------------------ | ----------------- | 11 | | `prose-base` *(default)* | 1rem *(16px)* | 12 | | `prose-lg` | 1.125rem *(18px)* | 13 | | `prose-xl` | 1.25rem *(20px)* | 14 | | `prose-2xl` | 1.5rem *(24px)* | -------------------------------------------------------------------------------- /JS/All/Chrome_Plugins/README.md: -------------------------------------------------------------------------------- 1 | # [Chrome Plugins](https://developer.chrome.com/extensions/devguide) 2 | 3 | - Chrome.runtime is available on any webpage 4 | - Since Manifest V3, can't use any remote code including any CDNs or packages that load code remotely 5 | 6 | To get file from built folder, 7 | 8 | ```js 9 | chrome.runtime.getURL("../myfile.html"); //relative path 10 | ``` 11 | 12 | Catch errors 13 | 14 | ```js 15 | chrome.runtime.lastError.message 16 | ``` 17 | 18 | ## Keep constant Chrome-ID 19 | 20 | Add key value to the manifest.json 21 | 22 | 1. Go to https://chrome.google.com/webstore/developer/dashboard/ and click more Info to get the key 23 | 3. Add that key value to your manifest.json 24 | 25 | -------------------------------------------------------------------------------- /JS/All/Chrome_Plugins/events.md: -------------------------------------------------------------------------------- 1 | # Events 2 | 3 | #### When Installed 4 | 5 | ```javascript 6 | chrome.runtime.onInstalled.addListener(() => { 7 | //...... 8 | }); 9 | ``` 10 | 11 | #### Bookmarks Created 12 | 13 | ```javascript 14 | chrome.bookmarks.onCreated.addListener(function() { 15 | //...... 16 | }); 17 | ``` 18 | 19 | #### Tab changes 20 | 21 | [tabs.onUpdated](https://developer.chrome.com/extensions/extensions/tabs#event-onUpdated) 22 | 23 | #### Navigation to Page 24 | 25 | webNavigation supports filters 26 | 27 | ```javascript 28 | chrome.webNavigation.onCompleted.addListener(() => { 29 | alert("This is my favorite website!"); 30 | }, {url: [{urlMatches : 'https://www.google.com/'}]}); 31 | ``` -------------------------------------------------------------------------------- /JS/All/Node/logging.md: -------------------------------------------------------------------------------- 1 | # Logging 2 | 3 | Could just use default `console.log` and `console.error` and then use bash redirects to a file 4 | 5 | ``` 6 | node index.js > regular.log 2> error.log 7 | ``` 8 | 9 | ## Packages 10 | 11 | - [`pino`](https://getpino.io/) 12 | - [`winston`](https://www.npmjs.com/package/winston) 13 | - [`roarr`](https://www.npmjs.com/package/roarr) 14 | - `log4js` 15 | 16 | allow for log levels, easy toggling logs on and off based on environment 17 | 18 | Logging frameworks will also (generally) support writing to more than just `stdout/stderr`. Winston calls these “transports” while Bunyan calls them “streams”. For example, you can configure writing to stdout, a file, and a database all at once. -------------------------------------------------------------------------------- /All/Python/packages/jupyter.md: -------------------------------------------------------------------------------- 1 | # Jupyter Notebook 2 | 3 | ### Setup 4 | 5 | ```bash 6 | pip install jupyter 7 | ``` 8 | 9 | ### Usage 10 | 11 | ```bash 12 | jupyter notebook 13 | ``` 14 | 15 | #### Magic Functions 16 | 17 | `%matplotlib inline` [sets the backend of matplotlib to the 'inline' backend](http://ipython.readthedocs.io/en/stable/interactive/plotting.html): 18 | 19 | > With this backend, the output of plotting commands is displayed inline within frontends like the Jupyter notebook, directly below the code cell that produced it. The resulting plots will then also be stored in the notebook document. 20 | 21 | ## Multiple Kernels/Environments 22 | 23 | In the environment, run `pip install ipykernel` 24 | 25 | -------------------------------------------------------------------------------- /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/Python/Django/serializers.md: -------------------------------------------------------------------------------- 1 | # Serializers 2 | 3 | `app/serializers.py` 4 | 5 | ```python 6 | from rest_framework import serializers 7 | from .models import Todo 8 | 9 | class TodoSerializer(serializers.ModelSerializer): 10 | class Meta: 11 | model = Todo 12 | fields = ('id', 'title', 'description', 'completed') 13 | ``` 14 | 15 | `app/views.py` 16 | 17 | ```python 18 | from django.shortcuts import render 19 | from rest_framework import viewsets 20 | from .serializers import TodoSerializer 21 | from .models import Todo 22 | 23 | # Create your views here. 24 | 25 | class TodoView(viewsets.ModelViewSet): 26 | serializer_class = TodoSerializer 27 | queryset = Todo.objects.all() 28 | ``` 29 | 30 | -------------------------------------------------------------------------------- /All/Python/packages/cython.md: -------------------------------------------------------------------------------- 1 | # Cython 2 | 3 | A superset of python with c data types that compiles to c code 4 | 5 | The c code it compiles to is long as fuck :( 6 | 7 | ## Basic Setup 8 | 9 | 1. Name python file to compile `.pyx` 10 | 11 | 2. In a `setup.py`, 12 | 13 | ```python 14 | from distutils.core import setup 15 | from Cython.Build import cythonize 16 | 17 | setup( 18 | ext_modules = cythonize(".pyx") 19 | ) 20 | ``` 21 | 22 | 3. Run this on the command line: `python setup.py build_ext --inplace` 23 | 24 | 1. This creates a .so and .c file 25 | 26 | 4. To use this in python just `import test` 27 | 28 | ## Variables 29 | 30 | ```python 31 | cdef int n, i, len_p 32 | ``` -------------------------------------------------------------------------------- /Deployment/AWS/Storage/DynamoDB.md: -------------------------------------------------------------------------------- 1 | # [DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Introduction.html) 2 | 3 | - NoSQL, fully managed, on demand autoscale 4 | - Supports document and key-value store models 5 | - Free Tier 6 | - DynamoDB won't let you write a bad query, which means you HAVE to have an index to do many queries 7 | - Query will be same speed at 100X scale unlike SQL 8 | 9 | 10 | ## Indexes 11 | 12 | Primary Keys - determine which partition its stored in, can also have sort key that determines order its in 13 | 14 | Secondary Keys - 15 | 16 | ## Creation 17 | 18 | Create Tables, 3 Options 19 | 20 | They will have items that are rows 21 | 22 | Amazon gives you UI to see it 23 | 24 | -------------------------------------------------------------------------------- /JS/closure.md: -------------------------------------------------------------------------------- 1 | # Closure 2 | 3 | Javascript has closures meaning functions defined store their environment when they are created 4 | 5 | ```js 6 | function makeFunc() { 7 | var name = 'Mozilla'; 8 | function displayName() { 9 | alert(name); 10 | } 11 | return displayName; 12 | } 13 | 14 | var myFunc = makeFunc(); 15 | myFunc(); //Mozilla 16 | ``` 17 | 18 | Can't rely on closure for global variables 19 | 20 | ```js 21 | let x = 100; 22 | let b = () => () => x; 23 | b()(); //100 24 | x = 10; 25 | b()(); //10 26 | ``` 27 | 28 | This works though 29 | 30 | ```js 31 | let x = 0; 32 | function y() {let z = x++; return () => z} 33 | let a = y(); 34 | let b = y(); 35 | x = 100; 36 | a(); //0 37 | b(); //1 38 | ``` 39 | 40 | -------------------------------------------------------------------------------- /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/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 -------------------------------------------------------------------------------- /React/All/Gatsby/cli.md: -------------------------------------------------------------------------------- 1 | # Cli 2 | 3 | ```bash 4 | gatsby new gatsby-site 5 | ``` 6 | 7 | ### Start development server 8 | 9 | ```bash 10 | gatsby develop 11 | ``` 12 | 13 | Gatsby will start a hot-reloading development environment accessible by default at `http://localhost:8000`. 14 | 15 | ### Create a production build 16 | 17 | ```shell 18 | gatsby build 19 | ``` 20 | 21 | Gatsby will perform an optimized production build for your site, generating static HTML and per-route JavaScript code bundles. 22 | 23 | ### Serve the production build locally 24 | 25 | ```shell 26 | gatsby serve 27 | ``` 28 | 29 | Gatsby starts a local HTML server for testing your built site. Remember to build your site using `gatsby build` before using this command. -------------------------------------------------------------------------------- /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/Python/packages/prisma.md: -------------------------------------------------------------------------------- 1 | # [Prisma*](https://prisma-client-py.readthedocs.io/) 2 | 3 | Uses async-io, dont forget to add client generator 4 | 5 | ``` 6 | generator client_py { 7 | provider = "prisma-client-py" 8 | recursive_type_depth = 5 9 | } 10 | ``` 11 | 12 | ## Setup 13 | 14 | ```bash 15 | pip install prisma 16 | ``` 17 | 18 | ## Usage 19 | 20 | ```python 21 | from prisma import Prisma 22 | 23 | db = Prisma() 24 | await db.connect() 25 | 26 | # CRUD operations 27 | user = await db.user.create(data={"name": "Alice"}) 28 | users = await db.user.find_many() 29 | updated = await db.user.update(where={"id": 1}, data={"name": "Bob"}) 30 | deleted = await db.user.delete(where={"id": 1}) 31 | 32 | await db.disconnect() 33 | ``` -------------------------------------------------------------------------------- /Deployment/AWS/VPC.md: -------------------------------------------------------------------------------- 1 | # Virtual Private Cloud (VPC) 2 | 3 | You control all resources inside VPC, can create subnets that isolate parts 4 | 5 | 10.10.0.0/16 : means first 16 bits are frozen 6 | 7 | Makes this the total VPC 8 | 9 | 10.10.1.0/24 means first 24 bits are frozen 10 | 11 | ## IGW 12 | 13 | All connections with subnet through internet gateway 14 | 15 | Attach it, add route table 16 | 17 | ## Create a private subnet 18 | 19 | Good for databases that shouldn't be accessed by outside 20 | 21 | Inside VPC can access each other 22 | 23 | ### Multiple Zones Elastic Load Blancer 24 | 25 | Launch many private subnets on another zone for high avalibility 26 | 27 | Use elastic load blancer to do it between subnets 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /JS/All/Chrome_Plugins/context_menu.md: -------------------------------------------------------------------------------- 1 | # Context Menu 2 | 3 | Can add stuff to the right click menu 4 | 5 | Need `"contextMenus"` permission in the manifest 6 | 7 | background.js 8 | 9 | ```js 10 | function searchUrbanDict(word) { 11 | debug("TESTING STUFF"); 12 | }; 13 | 14 | browser.contextMenus.create({ 15 | title: "Search in UrbanDictionary", 16 | contexts: ["selection"], // ContextType 17 | onclick: searchUrbanDict, // A callback function 18 | }); 19 | ``` 20 | 21 | #### ContextTypes 22 | 23 | `"all"`, `"page"`, `"frame"`, `"selection"`, `"link"`, `"editable"`, `"image"`, `"video"`, `"audio"`, `"launcher"`, `"browser_action"`, or `"page_action"` 24 | 25 | #### ItemTypes 26 | 27 | `"normal"`, `"checkbox"`, `"radio"`, or `"separator"` -------------------------------------------------------------------------------- /React/All/Prehooks/components.md: -------------------------------------------------------------------------------- 1 | ## Class Components 2 | 3 | ```js 4 | export default class Chat extends Component { 5 | constructor(props) { 6 | super(props); //needed 7 | //only place you can just use this.state to set 8 | this.state = { 9 | messageHistory: [], 10 | nextMessage: null 11 | }; 12 | 13 | //binding this ptr 14 | this.submitOption= this.submitOption.bind(this); 15 | this.getChromeStorage = this.getChromeStorage.bind(this); 16 | } 17 | 18 | componentDidMount() { 19 | this.getChromeStorage(); 20 | } 21 | 22 | componentDidUpdate() { 23 | this.msgAnchor.scrollIntoView({ behavior: 'smooth' }); 24 | } 25 | 26 | render() { 27 | //.... 28 | } 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/time.md: -------------------------------------------------------------------------------- 1 | # Dates 2 | 3 | Time package 4 | 5 | Package 6 | 7 | - `.Now()` 8 | 9 | Object 10 | 11 | - `.Month()`, `.Day()`, `.Weekday()` 12 | - `.addDate(0, 0, 1) 13 | 14 | ```go 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "time" 20 | ) 21 | 22 | func main() { 23 | t := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC) 24 | fmt.Printf("Go launched at %s\n", t) 25 | 26 | now := time.Now() 27 | 28 | } 29 | ``` 30 | 31 | ## Creating your format 32 | 33 | Based on Jan 2nd 3rd hours 4 minute 5 second and 6 year and -7 Time zone 34 | 35 | ```go 36 | longFormat := "Monday, Janurary 2, 2006" 37 | shortFormat := "1/2/06" 38 | fmt.Println("Tomorrow is", time.Now().Format(longFormat)) 39 | ``` 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /CSS/object-fit.md: -------------------------------------------------------------------------------- 1 | # [Object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) 2 | 3 | How content should be resized to fit container 4 | 5 | | Prop | Effect | 6 | | ----------------- | -------------------------------------- | 7 | | object-fit: fill; | stretch to fill | 8 | | contaiin | Keep aspect ratio | 9 | | Cover | Cover all of container even if cut off | 10 | | | | 11 | | | | 12 | | | | 13 | | | | 14 | 15 | -------------------------------------------------------------------------------- /All/HTML/Templating/README.md: -------------------------------------------------------------------------------- 1 | # TEMPLATING 2 | 3 | ## Intro 4 | 5 | - combination of data and layout 6 | - data and presentation are seperate 7 | - usually used to format repeating item 8 | 9 | ## Before Templating 10 | ```js 11 | var htmlStr = "
    " + 12 | "
    " + person.Name + "
    " + 13 | "
    " + person.Phone + "
    " + 14 | "
    " + person.Address + "
    " + 15 | "
    "; 16 | ``` 17 | 18 | SPecify placeholders dont worry about syntax 19 | 20 | twitter 21 | 22 | ## Quick Survey of JS Templating 23 | - jQuery Templating 24 | - Mustache 25 | - Handlebars 26 | - Backend Servers often have templating 27 | - ejx, pug, jade and node 28 | - python flask and jinja2 29 | - ruby on rails 30 | - php 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /All/Python/flask/postgres/migrate.md: -------------------------------------------------------------------------------- 1 | # Flask-Migrate 2 | 3 | ```bash 4 | pip install Flask-Migrate 5 | ``` 6 | 7 | Migrations are handle by `flask-migrate/alembic` 8 | 9 | Creates folder for migrations 10 | 11 | ## Setup 12 | 13 | ```python 14 | # extensions.py 15 | from flask_migrate import Migrate 16 | 17 | migrate = Migrate() 18 | 19 | # app.py 20 | from app.extensions import migrate 21 | 22 | #...... 23 | migrate.init_app(app, db) 24 | ``` 25 | 26 | Then run this to create the db tables 27 | 28 | ```bash 29 | flask db init 30 | flask db migrate -m "Message goes here I think" 31 | flask db upgrade 32 | ``` 33 | 34 | ## Generate New Migration Files 35 | 36 | ```bash 37 | flask db migrate -m "Message goes here I think" 38 | flask db upgrade 39 | ``` 40 | -------------------------------------------------------------------------------- /JS/packages/bcrypt.md: -------------------------------------------------------------------------------- 1 | # Bcrypt 2 | 3 | Cryptography/hashing lib, @node-rs/argon2 might be better 4 | 5 | ```bash 6 | npm install bcrypt 7 | ``` 8 | 9 | ## Basics 10 | 11 | ```javascript 12 | const bcrypt = require('bcrypt'); 13 | const saltRounds = 10; 14 | const myPlaintextPassword = 's0/\/\P4$$w0rD'; 15 | const someOtherPlaintextPassword = 'not_bacon'; 16 | 17 | //Hash Password 18 | bcrypt.hash(myPlaintextPassword, saltRounds).then(function(hash) { 19 | // Store hash in your password DB. 20 | }); 21 | 22 | // Load hash from your password DB. 23 | bcrypt.compare(myPlaintextPassword, hash).then(function(res) { 24 | // res == true 25 | }); 26 | bcrypt.compare(someOtherPlaintextPassword, hash).then(function(res) { 27 | // res == false 28 | }); 29 | ``` -------------------------------------------------------------------------------- /JS/webJS/README.md: -------------------------------------------------------------------------------- 1 | # JS In the Browser 2 | 3 | Include in HTML page with 4 | 5 | 6 | 7 | ## Running JS after DOM loads 8 | 9 | `defer` like above 10 | 11 | ```js 12 | window.onload = function() { 13 | init(); 14 | doSomethingElse(); 15 | }; 16 | ``` 17 | 18 | [window.onload](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers.onload) 19 | 20 | - By default, it is fired when the entire page loads, including its content (images, css, scripts, etc.) 21 | - In some browsers it now takes over the role of document.onload and fires when the DOM is ready as well. 22 | 23 | document.onload 24 | 25 | - It is called when the DOM is ready which can be prior to images and other external content is loaded. -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /React/state_management/redux/middleware.md: -------------------------------------------------------------------------------- 1 | # Middleware 2 | 3 | Intercept actions and does more logic/async/random code then dispatchs more actions or forwards to reducer or next middleware 4 | 5 | 6 | 7 | ### OG 8 | 9 | Can be thought of as editing the dispatch(next) of store by chaining them 10 | 11 | ```js 12 | import { createStore, combineReducers, applyMiddleware } from 'redux' 13 | 14 | const logger = store => next => action => { 15 | console.log('dispatching', action) 16 | let result = next(action) 17 | console.log('next state', store.getState()) 18 | return result 19 | } 20 | 21 | const store = createStore( 22 | todoApp, 23 | applyMiddleware(logger) 24 | ) 25 | ``` 26 | 27 | Apparently will hold the bulk of your applications logic 28 | 29 | -------------------------------------------------------------------------------- /All/HTML/optimizations.md: -------------------------------------------------------------------------------- 1 | # Optimizations 2 | 3 | ### Preconnect to Required Origins 4 | 5 | ##### Preconnect 6 | 7 | Easy to manage 8 | 9 | ```html 10 | 11 | ``` 12 | 13 | pretty cheap; should be used within 10 seconds 14 | 15 | Can save like .3ms 16 | 17 | ##### Preload 18 | 19 | `` informs the browser that a resource is needed as part of the current navigation, and that it should start getting fetched as soon as possible. 20 | 21 | Edge cases b/c this isnt a hint it mandates the browser grabs it 22 | 23 | ```html 24 | 25 | 26 | ``` 27 | 28 | Should be used within 3 seconds 29 | 30 | -------------------------------------------------------------------------------- /React/Next/app_router.md: -------------------------------------------------------------------------------- 1 | # App Router 2 | 3 | Next.js 13.4, released on May 4, 2023, marked the App Router as stable and ready for production use. v14 added Server Actions 4 | 5 | ## Updating versions 6 | 7 | - Routing 8 | - `/pages` => `/app` 9 | - [..slug].ts => [...slug]/page.ts 10 | - Client-side rendering ⇒ Server Components by default, need `use client` to change 11 | - Layouts in `_app.ts` => `layout.ts` an allows nested layouts(just include in folder) 12 | - `getStaticProps`, `getServerSideProps`, `getInitialProps` ⇒ Async server components can just call fetch 13 | - Custom pages like `404.js`, `500.js` ⇒ `error.js` and `global-error.js` for route segments and global errors 14 | - need to update image tags, not much benefit 15 | - metadata tags=> export metadata -------------------------------------------------------------------------------- /JS/All/Electron/messages.md: -------------------------------------------------------------------------------- 1 | # Messages 2 | 3 | ## From Main to Render 4 | 5 | Main 6 | 7 | ```js 8 | win.webContents.send('async-msg', 'pinggg'); 9 | ``` 10 | 11 | Renderer 12 | 13 | ```js 14 | ipc.on('reply', (event, arg) => { 15 | console.log("Message is ", arg); 16 | }) 17 | ``` 18 | 19 | ### From Render to Main 20 | 21 | main.js 22 | 23 | ```js 24 | import { ipcMain } from "electron"; 25 | 26 | ipcMain.on("async-msg", (event, arg) => { 27 | console.log(arg); 28 | event.sender.send('reply', 'pong'); 29 | }); 30 | ``` 31 | 32 | renderer.js 33 | 34 | ```js 35 | const ipc = require("electron").ipcRenderer; 36 | 37 | ipc.send("start-recording", "ping"); 38 | 39 | ipc.on('reply', (event, arg) => { 40 | console.log("Message is ", arg); 41 | }) 42 | ``` 43 | 44 | -------------------------------------------------------------------------------- /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/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/Python/flask/blueprint.md: -------------------------------------------------------------------------------- 1 | # Blueprint 2 | 3 | Split up your app routes into separate files and register them at like `/api/v1` 4 | 5 | ## Creation 6 | 7 | simplepage.py 8 | 9 | ```python 10 | from flask import Blueprint 11 | 12 | simple_page = Blueprint('simple_page', __name__, 13 | template_folder='templates') #can leave template_folders out 14 | 15 | @simple_page.route('/') 16 | def index(): 17 | return render_template("hello.html") 18 | ``` 19 | 20 | ## Registering 21 | 22 | app.py 23 | 24 | ```python 25 | from yourapplication.simple_page import simple_page 26 | 27 | app = Flask(__name__) 28 | app.register_blueprint(simple_page) 29 | 30 | app.register_blueprint(user, url_prefix='/user') 31 | ``` 32 | 33 | ## Linking 34 | url_for('admin.index') 35 | -------------------------------------------------------------------------------- /All/Python/json.md: -------------------------------------------------------------------------------- 1 | # JSON 2 | 3 | ```python 4 | import json 5 | ``` 6 | 7 | ## Dump vs Dumps 8 | 9 | `dumps`: returns a string 10 | 11 | `dump`: for printing out to file 12 | 13 | ```python 14 | someJson = {'x': 1, 'y': 57} 15 | print(json.dumps(someJson)) 16 | 17 | f1=open("test.txt", 'w') 18 | json.dump(someJson, f1) 19 | ``` 20 | 21 | ## Loads 22 | 23 | ``` 24 | json.loads(str) 25 | 26 | json.load(file) 27 | ``` 28 | 29 | 30 | 31 | 32 | 33 | ## Object ID 34 | 35 | ```python 36 | import json 37 | from bson import ObjectId 38 | 39 | class JSONEncoder(json.JSONEncoder): 40 | def default(self, o): 41 | if isinstance(o, ObjectId): 42 | return str(o) 43 | return json.JSONEncoder.default(self, o) 44 | 45 | JSONEncoder().encode(analytics) 46 | ``` -------------------------------------------------------------------------------- /JS/All/Electron/packages/electron-is-dev.md: -------------------------------------------------------------------------------- 1 | # Electron-is-Dev 2 | 3 | Simplest package ever, but it is recommended by the electron website so it must add value 4 | 5 | ```npm install electron-is-dev``` 6 | 7 | ```js 8 | const isDev = require('electron-is-dev'); 9 | 10 | if (isDev) { 11 | console.log('Running in development'); 12 | } else { 13 | console.log('Running in production'); 14 | } 15 | ``` 16 | 17 | ## The actual code lol 18 | 19 | ```js 20 | 'use strict'; 21 | const electron = require('electron'); 22 | 23 | const app = electron.app || electron.remote.app; 24 | 25 | const isEnvSet = 'ELECTRON_IS_DEV' in process.env; 26 | const getFromEnv = parseInt(process.env.ELECTRON_IS_DEV, 10) === 1; 27 | 28 | module.exports = isEnvSet ? getFromEnv : !app.isPackaged; 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /All/Python/collections/README.md: -------------------------------------------------------------------------------- 1 | # General Iterables 2 | 3 | `len(iterable)` 4 | 5 | #### Loop Over Two Iteratables 6 | 7 | ``` 8 | for (f,b) in zip(foo, bar): 9 | print "f: ", f ,"; b: ", b 10 | ``` 11 | 12 | Stops at the shorter of the two and works for an arbitrary number of iterables 13 | 14 | ## Functional 15 | 16 | In python3, map makes an generator object. Wrap with list() to make a list again 17 | 18 | Map 19 | 20 | ```python 21 | outputs = map(function_to_apply, inputs) 22 | 23 | list(outputs) 24 | ``` 25 | 26 | Filter 27 | 28 | ```python 29 | number_list = range(-5, 5) 30 | less_than_zero = list(filter(lambda x: x < 0, number_list)) 31 | ``` 32 | 33 | Reduce 34 | 35 | ```python 36 | from functools import reduce 37 | product = reduce((lambda x, y: x * y), [1, 2, 3, 4]) 38 | ``` -------------------------------------------------------------------------------- /React/Next/PreAppRouter/head.md: -------------------------------------------------------------------------------- 1 | # Head 2 | 3 | - Last Head to be rendered wins if there is a key 4 | 5 | ```react 6 | import Head from "next/head"; 7 | 8 | function App() { 9 | 10 | return (<> 11 | 12 | {conf.get("PROJECT_NAME")} 13 | 17 | 21 | 22 | 23 | ); 24 | } 25 | ``` 26 | 27 | Script 28 | 29 | ```jsx 30 | import Script from 'next/script' 31 | 32 | export default function Dashboard() { 33 | return ( 34 | <> 35 |