Skip to content

Instantly share code, notes, and snippets.

View blackavec's full-sized avatar
🎖️
Data Enthusiast

Mahan Hazrati blackavec

🎖️
Data Enthusiast
View GitHub Profile
@blackavec
blackavec / 2019-top10-languages-playgrounds.md
Created January 14, 2023 13:28
list of the top 10 popular programming languages according to Stack Overflow in 2021 and the associated playground (sandbox) platforms in markdown format
@blackavec
blackavec / gist:5962d455eb0697e61eb1578776f4edd0
Created August 28, 2022 16:49
How to flash ESP32 without holding reset/boot button
# Requirements
- 2x Resistors (10K)
- 2x Transistors (S8050)
- USB to UART Module
- ESP32
#!/bin/bash
#apt-get update
#apt-get upgrade -y
apt-get install build-essential
% node --print-bytecode --print-bytecode-filter=testFor scenarios/bytecode/benchmark.js
[generated bytecode for function: testFor]
Parameter count 2
Frame size 16
78 E> 0x596d72600ba @ 0 : a0 StackCheck
96 S> 0x596d72600bb @ 1 : 0c 0a LdaSmi [10]
0x596d72600bd @ 3 : 26 fb Star r0
102 E> 0x596d72600bf @ 5 : a0 StackCheck
116 S> 0x596d72600c0 @ 6 : 25 fb Ldar r0
0x596d72600c2 @ 8 : 73 00 ToNumeric [0]
function testFor(obj) {
let i = 10
for(;;) {
if (i-- === 0)
return true
}
}
function testWhile(obj) {
module.exports.scenario = function() {
let runCycles = totalExecutionLimit // 1,000,000,000
setInitialTime()
while (true) {
// do the calculation
add(2, 2)
if (!runCycles--)
break
module.exports.scenario = function() {
let runCycles = totalExecutionLimit // 1,000,000,000
setInitialTime()
for (;;) {
// do the calculation
add(2, 2)
if (!runCycles--)
break
module.exports.add = function(a, b) {
return a + b
}
2.hours.ago # => Fri, 02 Mar 2012 20:04:47 JST +09:00
1.day.from_now # => Fri, 03 Mar 2012 22:04:47 JST +09:00
Date.today.to_time_in_current_zone # => Fri, 02 Mar 2012 22:04:47 JST +09:00
Date.current # => Fri, 02 Mar
Time.zone.parse("2012-03-02 16:05:37") # => Fri, 02 Mar 2012 16:05:37 JST +09:00
Time.zone.now # => Fri, 02 Mar 2012 22:04:47 JST +09:00
Time.current # Same thing but shorter. (Thank you Lukas Sarnacki pointing this out.)
Time.zone.today # If you really can't have a Time or DateTime for some reason
Time.zone.now.utc.iso8601 # When supliyng an API (you can actually skip .zone here, but I find it better to always use it, than miss it when it's needed)
Time.strptime(time_string, '%Y-%m-%dT%H:%M:%S%z').in_time_zone(Time.zone) # If you can't use Time#parse
@blackavec
blackavec / tinder.bot.js
Created November 12, 2018 13:35
this script will start liking the profiles in a random time (human simulation) bases
window.startLiking = true
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
function getRandomTime(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}