Skip to content

Instantly share code, notes, and snippets.

@nelz9999
Created December 13, 2024 18:14
Show Gist options
  • Select an option

  • Save nelz9999/e4142839324ffca22ee8b6d58e5cc5cb to your computer and use it in GitHub Desktop.

Select an option

Save nelz9999/e4142839324ffca22ee8b6d58e5cc5cb to your computer and use it in GitHub Desktop.

Code Reading Interview Questions

Idea from this blog:

I've experimented with many types of interviews, but one thing I really dig lately is code reading. I print out 10-15 code snippets (not just code, but also UNIX commands, regular expressions, SQL queries and many other things). I then go through and ask: what does this snippet do, how does it work, are there any bugs, etc.? Reading code (as opposed to writing) means I can cover a lot of ground extremely quickly, spending no more than a minute or two on each problem.

Snippets

  1.  go build -ldflags "-X main.BuildSha=$CIRCLE_SHA1 -X main.BuildNum=$CIRCLE_BUILD_NUM" -o $BR/apiserver
  2.  func producer(chnl chan int) {  
         for i := 0; i < 10; i++ {
             chnl <- i
         }
         close(chnl)
     }
     func main() {  
         ch := make(chan int)
         go producer(ch)
         for v := range ch {
             fmt.Println("Received ",v)
         }
     }
  3.  resource "github_branch_protection" "kiddom-classroom3" {
       repository_id    = github_repository.kiddom_web.node_id
       pattern          = "feature.classroom3"
       enforce_admins   = true
       allows_deletions = false
    
       required_status_checks {
         strict = true
       }
    
       required_pull_request_reviews {
         required_approving_review_count = 1
       }
     }
  4.  {
       "compilerOptions": {
         "target": "ES5",
         "module": "ES2015",
         "allowJs": true,
         "jsx": "react",
         "sourceMap": true,
         "strict": true,
         "resolveJsonModule": true,
         "moduleResolution": "node",
         "allowSyntheticDefaultImports": true,
         "esModuleInterop": true,
         "experimentalDecorators": true,
         "emitDecoratorMetadata": true,
         "skipLibCheck": true,
         "forceConsistentCasingInFileNames": true
       },
       "exclude": [
         "node_modules",
         "./node_modules/**/*.stories.tsx"
       ],
       "include": [
         "**/*",
         "node_modules/@kiddom/ui/core/**/*",
         "node_modules/academy/src/**/*"
       ]
     }
  5.  FROM  cimg/go:1.17
     LABEL maintainer="Kiddom Engineering <[email protected]>"
     LABEL version="0.2"
    
     RUN sudo apt-get update && \
       sudo apt-get install -y \
       openjdk-11-jre-headless \
       python3 python3-cxx-dev python3-pip \
       ruby
    
     RUN sudo apt-get install -y default-mysql-client
     RUN sudo gem install parallel
    
     # installing cqlsh
     RUN sudo -H pip install cqlsh
  6.  /*
     query_id=aab32992-869d-4440-9f44-ef69cab9524e
     source=example/customer.php
     */
     (SELECT cust_id, surname, firstname 
    
       FROM customer ORDER BY cust_id LIMIT 3)
    
     UNION
    
     (SELECT cust_id, surname, firstname 
    
       FROM customer ORDER BY cust_id DESC LIMIT 3);
  7.  curl -H "Content-Type: application/json" \
       -H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
       -H "X-Auth-Key: $CLOUDFLARE_API_KEY" \
       -X POST "$CLOUDFLARE_API_ENDPOINT/$CLOUDFLARE_ZONE_ID/purge_cache" \
       --data '{"purge_everything": true}'
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment