Skip to content

Instantly share code, notes, and snippets.

View whal-e3's full-sized avatar

Eric Whale whal-e3

View GitHub Profile
@whal-e3
whal-e3 / vector_element_erasing.cpp
Created March 19, 2020 05:58
erasing multiple array elements
//Deleting multiple elements.
//solution is to make duplicated vector.
#include <iostream>
#include <vector>
int main() {
std::vector<int> array;
std::vector<int> arr;
for (int i = 0; i < array.size(); i++) {
@whal-e3
whal-e3 / vector_element_connect.cpp
Created March 19, 2020 06:08
connecting elements in every possible cases.
// How to connect elements in every possible cases.
#include <iostream>
#include <vector>
int main() {
// n : number of elements in vector
int n; std::cin >> n;
std::vector<int> vec(n);
for (int i = 0; i < n; i++) {
@whal-e3
whal-e3 / class_example.cpp
Created March 26, 2020 06:21
personally designed "class format snippet"
//C++ class example
#include <iostream>
#include <string>
class Box {
private:
int l;
int b;
long long int h;
@whal-e3
whal-e3 / Big integer multiplication using vector.cpp
Created March 30, 2020 05:10
Big integer multiplication method using vector! (Elements represent each number in decimal.)
#include <iostream>
#include <string>
#include <vector>
long long int reg_factorial(int num) {
long long int res = 1;
for (int i = num; i > 0; i--) res *= i;
return res;
}
std::vector<long long int> spe_factorial(int num) {
// EXAMINE THE DOCUMENT OBJECT // -- by Traversy Media
console.dir(document);
console.log(document.domain);
console.log(document.URL);
console.log(document.title);
//document.title = 123;
console.log(document.doctype);
console.log(document.head);
console.log(document.body);
@whal-e3
whal-e3 / postgreSQL_cheatsheet.txt
Last active October 19, 2020 12:49
PostgreSQL 13 cheat sheet
SELECT COUNT(DISTINCT(*)) FROM _somewhere_
WHERE _something_ <= 12 AND _something2_ = '_word_'
WHERE _something_ BETWEEN 8 AND 9
WHERE _something_ IN (0.99, 1.98, 1.99)
WHERE _something_ LIKE/ILIKE '_J%'
ORDER BY _something_ ASC, _something2_ DESC
LIMIT 5;
@whal-e3
whal-e3 / higherOrderFunction_Array.js
Last active November 10, 2020 13:25
forEach, filter, map, sort, reduce
// This file is used in youtube video "Traversy Media".
// visit "Traversy Media" down below
// https://www.youtube.com/watch?v=rRgD1yVwIvE&list=PLillGF-RfqbbnEGy3ROiLWk7JMCuSyQtX&index=9
const companies= [
{name: "Company One", category: "Finance", start: 1981, end: 2004},
{name: "Company Two", category: "Retail", start: 1992, end: 2008},
{name: "Company Three", category: "Auto", start: 1999, end: 2007},
{name: "Company Four", category: "Retail", start: 1989, end: 2010},
@whal-e3
whal-e3 / dom.js
Created October 27, 2020 05:03
JavaScript DOM manipulation & events
let val;
val = document;
// val = document.all;
// val = document.all[2];
val = document.head;
val = document.body;
val = document.doctype;
@whal-e3
whal-e3 / loc_storage.js
Created October 27, 2020 05:38
JavaScript Local/Session storage
// Local & Session storage
// Only difference = local - data remains // Session - erased when browser closed(session ends)
// --------------------------------------------------------------------
// set local storage item
localStorage.setItem('name', 'John');
localStorage.setItem('age', '30');
sessionStorage.setItem('name', 'Beth');
@whal-e3
whal-e3 / taskListForm.js
Created November 1, 2020 09:24
JS form of Task List application
// Define UI variables
const form = document.querySelector('#task-form');
const taskList = document.querySelector('.collection');
const clearBtn = document.querySelector('.clear-tasks');
const filter = document.querySelector('#filter');
const taskInput = document.querySelector('#task');
// Load all event listeners
loadEventListeners();