Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

ReSampled pointofpresence

🏠
Working from home
View GitHub Profile
@pointofpresence
pointofpresence / what_is_1e3.js
Last active May 5, 2023 22:05
From pointofpresence.ru
View what_is_1e3.js
> parseInt(1000)
1000
> parseInt(1000.0)
1000
> parseInt("1000.0")
1000
> parseInt(1e3)
@pointofpresence
pointofpresence / helpers.js
Created April 26, 2023 17:50
Array to number array
View helpers.js
const prev = oldVersion.split('.').map(Number);
const next = newVersion.split('.').map(Number);
@pointofpresence
pointofpresence / parser.js
Created April 20, 2023 06:56
get length of biggest nested array
View parser.js
const maxLength = Math.max(...sheetsArray.map(subArr => subArr.length));
@pointofpresence
pointofpresence / 1681973573.js
Created April 20, 2023 06:52
Created with Copy to Gist
View 1681973573.js
const arr = [[1, 2, 3], [4, 5], [6, 7, 8, 9]]; const result = []; for (let i = 0; i < arr.length; i++) { for (let j = 0; j < arr[i].length; j++) { if (!result[j]) result[j] = []; result[j].push(arr[i][j]); } } const flatResult = result.flat(); console.log(flatResult); // [1, 4, 6, 2, 5, 7, 3, 8, 9]
@pointofpresence
pointofpresence / quoteOfTheDay.js
Created February 21, 2023 08:38
Quote of the day
View quoteOfTheDay.js
const dtNow = new Date();
const intTZOffset = dtNow.getTimezoneOffset() * 60000; // automatically adjust for user timezone
const intNow = dtNow.getTime() - intTZOffset;
const intDay = Math.floor(intNow / 86400000); // The number of 'local' days since Jan 1, 1970
const randomIndex = intDay % QuotesData.length;
const item = QuotesData[randomIndex];
View chrome_get_page.py
def get_page(url):
ua = r'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36'
exe = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
args = f'"{exe}" --headless --disable-gpu --dump-dom --user-agent="{ua}" "{url}"'
sp = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = sp.communicate()
print(err, 'error') if err else None
return out.decode('utf-8') if out else ''
@pointofpresence
pointofpresence / 1673869519.txt
Created January 16, 2023 11:45
Created with Copy to Gist
View 1673869519.txt
Use the built-in function enumerate():
for idx, x in enumerate(xs):
print(idx, x)
@pointofpresence
pointofpresence / StyledConsoleLog.js
Created January 16, 2023 06:12
Styled console.log()
View StyledConsoleLog.js
console.log('%c[MESSAGES.SCHEDULE at ]', 'color: blue;font-weight:bold')
View module_websocketclient.pb
; Websocketclient by Netzvamp
; Version: 2016/01/08
DeclareModule WebsocketClient
Declare OpenWebsocketConnection(URL.s)
Declare SendTextFrame(connection, message.s)
Declare ReceiveFrame(connection, *MsgBuffer)
Declare SetSSLProxy(ProxyServer.s = "", ProxyPort.l = 8182)
Enumeration
@pointofpresence
pointofpresence / 1672591592.txt
Created January 1, 2023 16:41
Created with Copy to Gist
View 1672591592.txt
IsDevTools ! #True