{{ message }}

Instantly share code, notes, and snippets.

# scaryguy

• Silicon Valley
Created Nov 30, 2018
Two Pointers Technique (in JavaScript)
View two_pointers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 // This gist is for my YouTube video which I tried to explain Window Sliding Technique. // You can watch it from here: https://youtu.be/guDU5HnLqAs // Given a sorted array A (sorted in ascending order), having N integers, // find if there exists any pair of elements (A[i], A[j]) such that // their sum is equal to X. // // Input: A = [2,3,4,5,6,7,8,9], k= 10 // Output: true // NOTE: We slightly changed the question and the output in the video. We're returning pair indexes as an array.
Created Nov 29, 2018
Window Sliding Technique in JavaScript
View window_sliding_in_javascript.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 // This gist is for my YouTube video which I tried to explain Window Sliding Technique. // You can watch it from here: https://youtu.be/ZlnZkfEcbxs // // Given an array of integers of size ‘n’. Calculate the maximum sum possible // for ‘k’ consecutive elements in the array. // // Input : [10, 20, 30, 40, 50, 60, 70] // // k = 3 // Output : 180
Last active Jul 19, 2017
example json
View gist:6ec840c2896a35688530e185ab9a99b1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 { "speakers": [ { "firstname": "Ray", "lastname": "Villalobos", "category": "Front End", "title": "Bootstrap & CSS Preprocessors", "images": [{"one": "http://images1.luckygamez.com/eleminiscard.jpg"}, {"two": "http://barcampdeland.org/images/speaker_rayvillalobos.jpg"}, {"three": "http://barcampdeland.org/images/speaker_rayvillalobos.jpg"}], "link": "http://iviewsource.com", "bio": "Ray Villalobos is a full-time author and teacher at lynda.com. He is author of the book, Exploring Multimedia for Designers. He has more than 20 years experience in developing and programming multimedia projects. Previously at Entravision Communications, he designed and developed a network of radio station and TV web sites. As a senior producer for Tribune Interactive, he was responsible for designing orlandosentinel.com and for creating immersive multimedia projects and Flash games for the site.",
Last active Jul 27, 2022
How to change PRIMARY KEY of an existing PostgreSQL table?
View change_primary_key.md
```-- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY
ALTER TABLE <table_name> DROP CONSTRAINT <table_name>_pkey;```
```-- Then change column name of  your PRIMARY KEY and PRIMARY KEY candidates properly.
ALTER TABLE <table_name> RENAME COLUMN <primary_key_candidate> TO id;```
Last active Mar 21, 2022
How to reset ID column of a PostgreSQL table to let auto incrementation begin from 1?
View change_id_column
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # See your sequence name inside psql console with \ds command. ALTER SEQUENCE seq RESTART WITH 1; # Update sequence UPDATE table_name SET id=nextval('seq');