Skip to content

Instantly share code, notes, and snippets.

View projektorius96's full-sized avatar
🐢
Turtles do code

LG projektorius96

🐢
Turtles do code
View GitHub Profile
@projektorius96
projektorius96 / ES5vsES6.js
Created September 6, 2023 15:03 — forked from zeusdeux/ES5vsES6.js
ES5 inheritance vs ES6 inheritance
/* ES6/ES2015 classes */
class A {
constructor() {
this.a = 10
}
print() {
console.log(this.a, this.b)
}
}
@projektorius96
projektorius96 / lit-use-effect-element.js
Created September 3, 2023 23:18 — forked from Westbrook/lit-use-effect-element.js
useEffect() for `LitElement`... because everyone's doing it?
import {LitElement, html} from '@polymer/lit-element';
import {UseEffectMixin} from './use-effect.js';
class MyElement extends UseEffectMixin(LitElement) {
static get properties() {
return {
mood: {type: String},
expression: {type: String}
}
}
@projektorius96
projektorius96 / 1.README.md
Created April 11, 2023 22:27 — forked from varemenos/1.README.md
Git log in JSON format

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
@projektorius96
projektorius96 / greeter.js
Created November 8, 2022 15:15 — forked from mhofman/greeter.js
ES Module Dynamic export
const greeters = {
'en': 'english',
'fr': 'french'
};
const promise = (async () => {
const greeter = greeters[navigator.language.split('-')[0]];
if (!greeter) {
throw new Error('No greeter for you!');
@projektorius96
projektorius96 / lightweight_singleton.js
Created July 27, 2022 08:37
#1 shared on linkedin
let obj = Object.create(null) // prototypeless object
/* obj.propKey = propValue; */// prototypeless also means constructorless, resulting in the term of "singleton"
let isInstance = new obj
console.log(isInstance) // TypeError: obj is not a constructor – that's what you suppose to expect
// ===
// NOTE : constructorless can be prototype-based, but not vise versa with regards to example shown above !
// For more read about : @https://dev.to/projektorius96/constructorless-namespaces-in-es5-es6-14pk
@projektorius96
projektorius96 / c++ CRUD
Created February 13, 2022 22:03 — forked from nihitx/c++ CRUD
#include <iostream>
#include <vector>
#include <algorithm>
#include<array>
using namespace std;
int main()
{
cout << "** welcome to the database **" << endl;
char choice;
@projektorius96
projektorius96 / ISC.md
Created January 31, 2022 15:21 — forked from indexzero/ISC.md
ISC vs. MIT

Copyright (c) 4-digit year, Company or Person's Name

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Source: http://opensource.org/licenses/ISC

@projektorius96
projektorius96 / ANSI.md
Created November 30, 2021 19:39 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@projektorius96
projektorius96 / DriveUpload.gs
Created November 27, 2021 15:18 — forked from rcknr/DriveUpload.gs
This is a sample code to upload a PDF file to Google Drive with OCR in Apps Script. uploadPdfOcr function returns a File object. To run the code provide a developer key for an API Console project with Drive API service enabled.
function uploadPdfOcr() {
authorize();
var key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // <-- developer key
var file = UrlFetchApp.fetch("http://somewhere.com/path/file.pdf").getBlob();
var metadata = { title: file.getName() }
var params = {method:"post",
oAuthServiceName: "drive",
oAuthUseToken: "always",
contentType: "application/pdf",
contentLength: file.getBytes().length,

BANNER

Using Mongoose and AXIOS to upload APU data to MongoDB

Uploading data using Axios and Mongoose can be hard at first. But when you really understand what you are doing you will be glad you are not reaching out to the API each time someone loads your webpage.

Installing the Packages

  1. Make sure you have nodejs and NPM installed, NPM comes with nodejs

npm install axios mongoose