-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
1186 lines (1113 loc) · 43.1 KB
/
app.js
File metadata and controls
1186 lines (1113 loc) · 43.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Command data organized by category
const commandData = {
"linux": [
{
"command": "ls -la",
"description": "List all files and directories with detailed information including hidden files",
"usage": "View complete directory contents with permissions and timestamps"
},
{
"command": "pwd",
"description": "Print current working directory path",
"usage": "Know your current location in the file system"
},
{
"command": "cd /path/to/directory",
"description": "Change current directory to specified path",
"usage": "Navigate through directory structure"
},
{
"command": "mkdir -p path/to/new/directory",
"description": "Create directory with parent directories if needed",
"usage": "Create nested directory structures for data projects"
},
{
"command": "cp -r source destination",
"description": "Copy files or directories recursively",
"usage": "Backup data files or replicate directory structures"
},
{
"command": "mv oldname newname",
"description": "Move or rename files and directories",
"usage": "Reorganize data files and folders"
},
{
"command": "rm -rf directory",
"description": "Remove files and directories recursively (use with caution)",
"usage": "Clean up temporary files and old data"
},
{
"command": "find . -name '*.csv' -type f",
"description": "Find all CSV files in current directory and subdirectories",
"usage": "Locate specific data files in large directory structures"
},
{
"command": "grep -r 'pattern' /path",
"description": "Search for text pattern recursively in files",
"usage": "Find specific content in log files or configuration files"
},
{
"command": "tail -f /var/log/application.log",
"description": "Display last lines of file and follow new additions in real-time",
"usage": "Monitor data pipeline logs and application outputs"
},
{
"command": "head -n 20 datafile.csv",
"description": "Display first 20 lines of a file",
"usage": "Preview data file contents and structure"
},
{
"command": "wc -l filename",
"description": "Count number of lines in a file",
"usage": "Get record count for data validation"
},
{
"command": "du -sh /path/to/directory",
"description": "Display disk usage of directory in human readable format",
"usage": "Monitor data storage consumption"
},
{
"command": "df -h",
"description": "Display filesystem disk space usage in human readable format",
"usage": "Check available storage for data operations"
},
{
"command": "chmod 755 script.sh",
"description": "Change file permissions to make script executable",
"usage": "Set proper permissions for data processing scripts"
},
{
"command": "ps aux | grep python",
"description": "List all processes and filter for Python processes",
"usage": "Monitor running data processing jobs"
},
{
"command": "kill -9 PID",
"description": "Force kill a process by its process ID",
"usage": "Stop stuck or runaway data processing jobs"
},
{
"command": "top",
"description": "Display real-time system processes and resource usage",
"usage": "Monitor system performance during data processing"
},
{
"command": "htop",
"description": "Enhanced version of top with better interface",
"usage": "Advanced system monitoring for resource-intensive data operations"
},
{
"command": "free -h",
"description": "Display memory usage in human readable format",
"usage": "Monitor available RAM for data processing jobs"
}
],
"bash": [
{
"command": "#!/bin/bash",
"description": "Shebang line to specify bash interpreter for scripts",
"usage": "Start all bash scripts for data pipelines"
},
{
"command": "for file in *.csv; do echo $file; done",
"description": "Loop through all CSV files in current directory",
"usage": "Process multiple data files in batch operations"
},
{
"command": "if [ -f 'file.csv' ]; then echo 'exists'; fi",
"description": "Check if file exists before processing",
"usage": "Validate input files in data pipeline scripts"
},
{
"command": "variable='value'",
"description": "Assign value to variable (no spaces around =)",
"usage": "Store configuration values and file paths in scripts"
},
{
"command": "echo $variable",
"description": "Print variable value to stdout",
"usage": "Display script progress and variable values for debugging"
},
{
"command": "command1 | command2",
"description": "Pipe output from first command to second command",
"usage": "Chain data processing commands together"
},
{
"command": "command > output.txt",
"description": "Redirect command output to file (overwrites file)",
"usage": "Save data processing results to files"
},
{
"command": "command >> output.txt",
"description": "Redirect command output to file (appends to file)",
"usage": "Append new data to existing result files"
},
{
"command": "command 2>&1",
"description": "Redirect both stdout and stderr to same destination",
"usage": "Capture all script output including errors for logging"
},
{
"command": "nohup command &",
"description": "Run command in background, immune to hangups",
"usage": "Run long-running data processing jobs"
},
{
"command": "crontab -e",
"description": "Edit user's cron jobs for scheduled tasks",
"usage": "Schedule automated data pipeline executions"
},
{
"command": "0 2 * * * /path/to/script.sh",
"description": "Cron expression to run script daily at 2 AM",
"usage": "Schedule daily data processing jobs"
},
{
"command": "awk -F, '{print $1,$3}' file.csv",
"description": "Extract specific columns from CSV using comma delimiter",
"usage": "Extract specific fields from structured data files"
},
{
"command": "sed 's/old/new/g' file.txt",
"description": "Replace all occurrences of 'old' with 'new' in file",
"usage": "Clean and standardize data values in text files"
},
{
"command": "sort -k 2 -n file.csv",
"description": "Sort file numerically by second column",
"usage": "Sort data records by specific numeric fields"
},
{
"command": "uniq -c sorted_file.txt",
"description": "Count unique lines in sorted file",
"usage": "Analyze data frequency and remove duplicates"
},
{
"command": "cut -d, -f1,3 file.csv",
"description": "Extract columns 1 and 3 from comma-separated file",
"usage": "Select specific columns from structured data"
},
{
"command": "join file1.txt file2.txt",
"description": "Join lines from two sorted files on common field",
"usage": "Combine data from multiple sorted data sources"
},
{
"command": "paste file1.txt file2.txt",
"description": "Merge lines from files side by side",
"usage": "Combine data columns from multiple files"
}
],
"git": [
{
"command": "git init",
"description": "Initialize a new Git repository in current directory",
"usage": "Start version control for new data engineering projects"
},
{
"command": "git clone <repository-url>",
"description": "Clone a remote repository to local machine",
"usage": "Get existing data engineering projects and collaborate"
},
{
"command": "git add .",
"description": "Stage all modified files for commit",
"usage": "Prepare all changed files for version control"
},
{
"command": "git add filename",
"description": "Stage specific file for commit",
"usage": "Selectively stage specific data pipeline files"
},
{
"command": "git commit -m 'message'",
"description": "Commit staged changes with descriptive message",
"usage": "Save changes to project history with meaningful descriptions"
},
{
"command": "git status",
"description": "Show current repository status and modified files",
"usage": "Check which files have been modified in data projects"
},
{
"command": "git push origin main",
"description": "Push local commits to remote main branch",
"usage": "Share data pipeline changes with team"
},
{
"command": "git pull origin main",
"description": "Fetch and merge changes from remote main branch",
"usage": "Get latest updates from team members"
},
{
"command": "git branch feature-name",
"description": "Create new branch for feature development",
"usage": "Develop new data pipeline features in isolation"
},
{
"command": "git checkout branch-name",
"description": "Switch to specified branch",
"usage": "Work on different data pipeline features or environments"
},
{
"command": "git checkout -b new-branch",
"description": "Create and switch to new branch in one command",
"usage": "Start new feature development quickly"
},
{
"command": "git merge feature-branch",
"description": "Merge feature branch into current branch",
"usage": "Integrate completed data pipeline features"
},
{
"command": "git log --oneline",
"description": "Show commit history in compact format",
"usage": "Review data pipeline development history"
},
{
"command": "git diff",
"description": "Show unstaged changes in working directory",
"usage": "Review code changes before staging"
},
{
"command": "git diff --staged",
"description": "Show staged changes ready for commit",
"usage": "Review changes before committing to repository"
},
{
"command": "git stash",
"description": "Temporarily save uncommitted changes",
"usage": "Save work in progress when switching contexts"
},
{
"command": "git stash pop",
"description": "Apply most recent stashed changes and remove from stash",
"usage": "Restore temporarily saved work"
},
{
"command": "git reset --hard HEAD~1",
"description": "Reset to previous commit, discarding all changes",
"usage": "Undo commits and changes (use with caution)"
},
{
"command": "git tag v1.0.0",
"description": "Create lightweight tag for current commit",
"usage": "Mark data pipeline releases and versions"
},
{
"command": "git remote -v",
"description": "Show remote repository URLs",
"usage": "Verify remote repository connections"
}
],
"databricks": [
{
"command": "databricks configure",
"description": "Configure Databricks CLI with authentication credentials",
"usage": "Set up CLI access to Databricks workspace"
},
{
"command": "databricks clusters list",
"description": "List all available clusters in workspace",
"usage": "View available compute resources for data processing"
},
{
"command": "databricks clusters start --cluster-id <id>",
"description": "Start a specific cluster by ID",
"usage": "Spin up compute resources for data processing jobs"
},
{
"command": "databricks clusters terminate --cluster-id <id>",
"description": "Terminate a running cluster to save costs",
"usage": "Stop compute resources when not needed"
},
{
"command": "databricks fs ls dbfs:/",
"description": "List files and directories in Databricks File System",
"usage": "Navigate and explore data stored in DBFS"
},
{
"command": "databricks fs cp local_file.csv dbfs:/path/",
"description": "Copy local file to Databricks File System",
"usage": "Upload data files for processing in Databricks"
},
{
"command": "databricks fs cp dbfs:/path/file.csv ./",
"description": "Copy file from DBFS to local machine",
"usage": "Download processed results from Databricks"
},
{
"command": "databricks jobs list",
"description": "List all jobs in the Databricks workspace",
"usage": "View scheduled and available data processing jobs"
},
{
"command": "databricks jobs run-now --job-id <id>",
"description": "Trigger immediate execution of specified job",
"usage": "Manually run data pipelines and ETL jobs"
},
{
"command": "databricks runs list --job-id <id>",
"description": "List all runs for a specific job",
"usage": "Monitor job execution history and status"
},
{
"command": "databricks workspace list /",
"description": "List workspace contents at root level",
"usage": "Navigate notebooks and workspace resources"
},
{
"command": "databricks workspace export /path/notebook.py ./",
"description": "Export notebook from workspace to local file",
"usage": "Backup notebooks and share code outside Databricks"
},
{
"command": "databricks workspace import ./notebook.py /path/",
"description": "Import local file as notebook to workspace",
"usage": "Deploy notebooks from version control to Databricks"
},
{
"command": "databricks libraries cluster-status --cluster-id <id>",
"description": "Check library installation status on cluster",
"usage": "Verify required packages are available for data processing"
},
{
"command": "databricks current-user me",
"description": "Display current user information",
"usage": "Verify authentication and user permissions"
}
],
"curl": [
{
"command": "curl https://api.example.com/data",
"description": "Make simple GET request to API endpoint",
"usage": "Retrieve data from REST APIs for ingestion"
},
{
"command": "curl -X POST https://api.example.com/data",
"description": "Send POST request to API endpoint",
"usage": "Submit data to APIs or trigger data processing"
},
{
"command": "curl -H 'Authorization: Bearer token' url",
"description": "Send request with authorization header",
"usage": "Access protected APIs with authentication tokens"
},
{
"command": "curl -H 'Content-Type: application/json' url",
"description": "Specify content type in request header",
"usage": "Send JSON data to APIs properly formatted"
},
{
"command": "curl -d '{key:value}' url",
"description": "Send JSON data in POST request body",
"usage": "Submit structured data to APIs"
},
{
"command": "curl -d @data.json url",
"description": "Send JSON data from file in request body",
"usage": "Upload data files to APIs"
},
{
"command": "curl -o output.json url",
"description": "Save response to specified file",
"usage": "Download data from APIs to local files"
},
{
"command": "curl -L url",
"description": "Follow HTTP redirects automatically",
"usage": "Handle API redirects transparently"
},
{
"command": "curl -v url",
"description": "Enable verbose output showing request/response details",
"usage": "Debug API interactions and troubleshoot issues"
},
{
"command": "curl -s url",
"description": "Silent mode - suppress progress and error output",
"usage": "Clean API responses for automated processing"
},
{
"command": "curl -w '%{http_code}' url",
"description": "Output HTTP status code after request",
"usage": "Check API response status in automated scripts"
},
{
"command": "curl --retry 3 url",
"description": "Retry failed requests up to 3 times",
"usage": "Handle temporary API failures in data pipelines"
},
{
"command": "curl --max-time 30 url",
"description": "Set maximum time for entire operation",
"usage": "Prevent hanging requests in automated data collection"
},
{
"command": "curl -u username:password url",
"description": "Use basic authentication with username/password",
"usage": "Access APIs requiring basic authentication"
},
{
"command": "curl --json '{data:value}' url",
"description": "Send JSON with automatic content-type header (curl 7.82+)",
"usage": "Modern way to send JSON data to APIs"
}
],
"docker": [
{
"command": "docker run -d --name container-name image",
"description": "Run container in background with custom name",
"usage": "Deploy data processing services and databases"
},
{
"command": "docker run -it ubuntu bash",
"description": "Run container interactively with terminal",
"usage": "Debug and test data processing environments"
},
{
"command": "docker ps",
"description": "List currently running containers",
"usage": "Monitor active data processing containers"
},
{
"command": "docker ps -a",
"description": "List all containers including stopped ones",
"usage": "View complete container history and status"
},
{
"command": "docker images",
"description": "List available Docker images",
"usage": "Manage data processing environment images"
},
{
"command": "docker pull image-name:tag",
"description": "Download image from Docker registry",
"usage": "Get latest data processing tools and databases"
},
{
"command": "docker build -t image-name .",
"description": "Build image from Dockerfile in current directory",
"usage": "Create custom data processing environments"
},
{
"command": "docker exec -it container-name bash",
"description": "Execute interactive shell in running container",
"usage": "Debug running data processing containers"
},
{
"command": "docker logs container-name",
"description": "View container logs and output",
"usage": "Monitor data pipeline execution and debug issues"
},
{
"command": "docker logs -f container-name",
"description": "Follow container logs in real-time",
"usage": "Monitor live data processing job outputs"
},
{
"command": "docker stop container-name",
"description": "Stop running container gracefully",
"usage": "Shut down data processing services properly"
},
{
"command": "docker rm container-name",
"description": "Remove stopped container",
"usage": "Clean up completed data processing jobs"
},
{
"command": "docker rmi image-name",
"description": "Remove Docker image from local system",
"usage": "Free up storage space from unused images"
},
{
"command": "docker-compose up -d",
"description": "Start multi-container application in background",
"usage": "Deploy complete data processing stacks"
},
{
"command": "docker-compose down",
"description": "Stop and remove multi-container application",
"usage": "Tear down complete data processing environments"
},
{
"command": "docker volume create volume-name",
"description": "Create named volume for persistent storage",
"usage": "Persist data across container restarts"
},
{
"command": "docker run -v volume-name:/data image",
"description": "Mount named volume to container directory",
"usage": "Ensure data persistence in processing containers"
},
{
"command": "docker stats",
"description": "Display real-time container resource usage",
"usage": "Monitor container performance and resource consumption"
},
{
"command": "docker system prune -a",
"description": "Remove unused containers, images, and networks",
"usage": "Clean up Docker system and free storage space"
}
],
"sql": [
{
"command": "SELECT * FROM table_name;",
"description": "Retrieve all columns and rows from table",
"usage": "Explore data structure and content"
},
{
"command": "SELECT column1, column2 FROM table_name;",
"description": "Retrieve specific columns from table",
"usage": "Extract only needed data fields"
},
{
"command": "SELECT * FROM table_name WHERE condition;",
"description": "Filter rows based on specified condition",
"usage": "Extract data meeting specific criteria"
},
{
"command": "SELECT COUNT(*) FROM table_name;",
"description": "Count total number of rows in table",
"usage": "Data quality checks and validation"
},
{
"command": "SELECT DISTINCT column FROM table_name;",
"description": "Get unique values from specified column",
"usage": "Identify unique categories and data profiling"
},
{
"command": "SELECT * FROM table_name ORDER BY column ASC;",
"description": "Sort results by column in ascending order",
"usage": "Organize data for analysis and reporting"
},
{
"command": "SELECT * FROM table_name LIMIT 10;",
"description": "Limit results to specified number of rows",
"usage": "Sample data for testing and preview"
},
{
"command": "INSERT INTO table_name (col1, col2) VALUES (val1, val2);",
"description": "Insert new row with specified values",
"usage": "Add new data records to tables"
},
{
"command": "UPDATE table_name SET column = value WHERE condition;",
"description": "Update existing rows matching condition",
"usage": "Modify data values during ETL processes"
},
{
"command": "DELETE FROM table_name WHERE condition;",
"description": "Remove rows matching specified condition",
"usage": "Clean data and remove invalid records"
},
{
"command": "CREATE TABLE table_name (column1 TYPE, column2 TYPE);",
"description": "Create new table with specified schema",
"usage": "Define data structures for new datasets"
},
{
"command": "DROP TABLE table_name;",
"description": "Delete table and all its data permanently",
"usage": "Remove obsolete tables (use with caution)"
},
{
"command": "ALTER TABLE table_name ADD COLUMN new_col TYPE;",
"description": "Add new column to existing table",
"usage": "Extend table schema for additional data"
},
{
"command": "SELECT t1.*, t2.column FROM table1 t1 JOIN table2 t2 ON t1.id = t2.id;",
"description": "Join two tables on common column",
"usage": "Combine data from multiple related tables"
},
{
"command": "SELECT column, COUNT(*) FROM table_name GROUP BY column;",
"description": "Group rows and count occurrences per group",
"usage": "Aggregate data for analysis and reporting"
},
{
"command": "SELECT column, SUM(value) FROM table_name GROUP BY column HAVING SUM(value) > 100;",
"description": "Group data and filter groups by aggregate condition",
"usage": "Advanced aggregation with group-level filtering"
},
{
"command": "WITH cte AS (SELECT * FROM table WHERE condition) SELECT * FROM cte;",
"description": "Create Common Table Expression for complex queries",
"usage": "Break down complex queries into readable parts"
},
{
"command": "CREATE INDEX idx_name ON table_name (column);",
"description": "Create index on column for faster queries",
"usage": "Optimize query performance on large tables"
},
{
"command": "EXPLAIN SELECT * FROM table_name WHERE condition;",
"description": "Show query execution plan and performance details",
"usage": "Analyze and optimize query performance"
}
],
"tools": [
{
"command": "jq '.field' data.json",
"description": "Extract specific field from JSON file",
"usage": "Parse and transform JSON API responses"
},
{
"command": "jq '.[] | select(.status == 'active')' data.json",
"description": "Filter JSON array by field value",
"usage": "Filter data from API responses"
},
{
"command": "pgcli -h localhost -U postgres -d database",
"description": "Connect to PostgreSQL with enhanced CLI features",
"usage": "Interactive PostgreSQL sessions with autocomplete"
},
{
"command": "vd file.csv",
"description": "Open CSV file in VisiData spreadsheet interface",
"usage": "Interactively explore and analyze data files"
},
{
"command": "bat filename",
"description": "Display file contents with syntax highlighting",
"usage": "View code and data files with better formatting"
},
{
"command": "fzf",
"description": "Fuzzy finder for interactive file and command search",
"usage": "Quickly find files, commands, and data in directories"
},
{
"command": "httpie GET https://api.example.com/data",
"description": "Make HTTP requests with user-friendly syntax",
"usage": "Test APIs with more readable syntax than curl"
},
{
"command": "lnav /var/log/application.log",
"description": "Navigate and search log files with SQL queries",
"usage": "Analyze application and system logs efficiently"
},
{
"command": "csvkit in2csv data.xlsx > data.csv",
"description": "Convert Excel file to CSV format",
"usage": "Convert various data formats for processing"
},
{
"command": "csvstat data.csv",
"description": "Generate statistical summary of CSV file",
"usage": "Quick data profiling and quality assessment"
},
{
"command": "q 'SELECT * FROM data.csv WHERE column > 100'",
"description": "Run SQL queries directly on CSV files",
"usage": "Query CSV files without loading into database"
},
{
"command": "miller --csv cut -f field1,field3 data.csv",
"description": "Process CSV files with Miller data processing tool",
"usage": "Transform and manipulate structured data files"
},
{
"command": "dvc add data/raw_data.csv",
"description": "Add data file to DVC (Data Version Control)",
"usage": "Version control large datasets efficiently"
},
{
"command": "great_expectations init",
"description": "Initialize Great Expectations for data validation",
"usage": "Set up data quality testing framework"
},
{
"command": "airflow dags list",
"description": "List all available Airflow DAGs",
"usage": "View available data pipeline workflows"
}
]
};
// Category configuration
const categoryConfig = {
"linux": { icon: "fab fa-linux", title: "Linux Commands", count: 20 },
"bash": { icon: "fas fa-terminal", title: "Bash/Shell Commands", count: 19 },
"git": { icon: "fab fa-git-alt", title: "Git Commands", count: 20 },
"databricks": { icon: "fas fa-database", title: "Databricks CLI Commands", count: 15 },
"curl": { icon: "fas fa-globe", title: "Curl Commands", count: 15 },
"docker": { icon: "fab fa-docker", title: "Docker Commands", count: 19 },
"sql": { icon: "fas fa-table", title: "SQL Commands", count: 19 },
"tools": { icon: "fas fa-tools", title: "Additional CLI Tools", count: 15 }
};
// Global variables
let currentCategory = 'all';
let searchTerm = '';
let allCommands = [];
// DOM elements
let elements = {};
// Initialize the application
document.addEventListener('DOMContentLoaded', function() {
initializeElements();
initializeTheme();
initializeCommands();
renderCommands();
setupEventListeners();
setupIntersectionObserver();
hideLoading();
});
// Initialize DOM elements
function initializeElements() {
elements = {
searchInput: document.getElementById('search-input'),
clearSearchBtn: document.getElementById('clear-search'),
backToTopBtn: document.getElementById('back-to-top'),
themeToggleBtn: document.getElementById('theme-toggle'),
themeIcon: document.getElementById('theme-icon'),
sections: document.getElementById('command-sections'),
noResults: document.getElementById('no-results'),
loading: document.getElementById('loading'),
navItems: document.querySelectorAll('.nav-item')
};
}
// Initialize theme
function initializeTheme() {
const savedTheme = localStorage.getItem('theme') || 'light';
document.body.className = savedTheme;
updateThemeIcon(savedTheme);
}
// Update theme icon
function updateThemeIcon(theme) {
if (elements.themeIcon) {
elements.themeIcon.className = theme === 'dark' ? 'fas fa-sun' : 'fas fa-moon';
}
}
// Toggle theme
function toggleTheme() {
const currentTheme = document.body.className || 'light';
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
document.body.className = newTheme;
localStorage.setItem('theme', newTheme);
updateThemeIcon(newTheme);
}
// Initialize commands array
function initializeCommands() {
allCommands = [];
Object.keys(commandData).forEach(category => {
commandData[category].forEach(cmd => {
allCommands.push({
...cmd,
category: category
});
});
});
}
// Hide loading indicator
function hideLoading() {
if (elements.loading) {
elements.loading.style.display = 'none';
}
}
// Render commands based on current filters
function renderCommands() {
if (!elements.sections) return;
const filteredCommands = getFilteredCommands();
const groupedCommands = groupCommandsByCategory(filteredCommands);
elements.sections.innerHTML = '';
if (filteredCommands.length === 0) {
showNoResults();
return;
}
hideNoResults();
Object.keys(groupedCommands).forEach(category => {
const section = createSection(category, groupedCommands[category]);
elements.sections.appendChild(section);
});
}
// Get filtered commands based on search and category
function getFilteredCommands() {
let filtered = allCommands;
// Filter by category
if (currentCategory !== 'all') {
filtered = filtered.filter(cmd => cmd.category === currentCategory);
}
// Filter by search term
if (searchTerm) {
filtered = filtered.filter(cmd =>
cmd.command.toLowerCase().includes(searchTerm) ||
cmd.description.toLowerCase().includes(searchTerm) ||
cmd.usage.toLowerCase().includes(searchTerm)
);
}
return filtered;
}
// Group commands by category
function groupCommandsByCategory(commands) {
const grouped = {};
commands.forEach(cmd => {
if (!grouped[cmd.category]) {
grouped[cmd.category] = [];
}
grouped[cmd.category].push(cmd);
});
return grouped;
}
// Create a section element
function createSection(category, commands) {
const config = categoryConfig[category];
if (!config) return document.createElement('div');
const section = document.createElement('section');
section.className = 'section';
section.setAttribute('data-category', category);
const sectionHeader = document.createElement('div');
sectionHeader.className = 'section-header';
sectionHeader.onclick = () => toggleSection(section);
sectionHeader.innerHTML = `
<div class="section-title-wrapper">
<i class="${config.icon} section-icon"></i>
<h2 class="section-title">${config.title}</h2>
<span class="command-count">${commands.length} commands</span>
</div>
<button class="toggle-section" aria-label="Toggle section">
<i class="fas fa-chevron-down"></i>
</button>
`;
const sectionContent = document.createElement('div');
sectionContent.className = 'section-content';
const commandsGrid = document.createElement('div');
commandsGrid.className = 'commands-grid';
commands.forEach((cmd, index) => {
const commandCard = createCommandCard(cmd, category, index);
commandsGrid.appendChild(commandCard);
});
sectionContent.appendChild(commandsGrid);
section.appendChild(sectionHeader);
section.appendChild(sectionContent);
return section;
}
// Create a command card
function createCommandCard(command, category, index) {
const card = document.createElement('div');
card.className = 'command-card';
card.setAttribute('data-command', command.command.toLowerCase());
card.setAttribute('data-description', command.description.toLowerCase());
const cardId = `${category}-${index}`;
card.innerHTML = `
<div class="command-header">
<code class="command-text">${escapeHtml(command.command)}</code>
<button class="copy-btn" onclick="copyCommand('${escapeHtml(command.command)}')" aria-label="Copy command">
<i class="fas fa-copy"></i>
</button>
</div>
<div class="command-description">${escapeHtml(command.description)}</div>
<div class="command-usage">${escapeHtml(command.usage)}</div>
`;
return card;
}
// Escape HTML to prevent XSS
function escapeHtml(text) {
const map = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": '''
};
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
}
// Toggle section visibility
function toggleSection(section) {
section.classList.toggle('collapsed');
}
// Copy command to clipboard
async function copyCommand(command) {
try {
// Decode HTML entities for copying
const decodedCommand = command
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, "'");
await navigator.clipboard.writeText(decodedCommand);
// Find the button that was clicked and show feedback
const buttons = document.querySelectorAll('.copy-btn');
buttons.forEach(btn => {
if (btn.getAttribute('onclick').includes(command)) {
showCopyFeedback(btn);
}
});
} catch (err) {
console.error('Failed to copy command:', err);
// Fallback for older browsers
fallbackCopyTextToClipboard(command);
}
}
// Show copy feedback
function showCopyFeedback(button) {
const originalHTML = button.innerHTML;
button.innerHTML = '<i class="fas fa-check"></i>';
button.classList.add('copied');
setTimeout(() => {
button.innerHTML = originalHTML;
button.classList.remove('copied');
}, 2000);
}
// Fallback copy function
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement("textarea");