Skip to content

Instantly share code, notes, and snippets.

View blackavec's full-sized avatar
🎡
Coding & Composing

Mahan Sagharchi blackavec

🎡
Coding & Composing
View GitHub Profile
@blackavec
blackavec / gulp.js
Created January 18, 2018 09:19 — forked from merlinvn/gulp.js
Gulp for C++
var gulp = require('gulp');
var exec = require('child_process').exec;
var cmakeCommand = "mkdir -p build; cd build; cmake ..;";
var cleanCommand = "rm -rf build";
var testCommand = "cd build; ctest -V";
//"cmake --build ."
/**
* Validate brackets
* write a function that accepts a string and validates braces/brackets/parentheses
* β€˜(β€˜, β€˜{β€˜, β€˜[β€˜ are openers
* β€˜)’, β€˜}’, β€˜]’ closers
* β€˜{ [ }’ should return false
* β€˜{ [ ] ( ) }’ should return true
**/
const signMap = {
@blackavec
blackavec / random string.js
Last active April 3, 2018 06:02
create Random string from input in length of 8 char
function getRandomIntInclusive (min, max) {
min = Math.ceil(min)
max = Math.floor(max)
return Math.floor(Math.random() * (max - min + 1)) + min
}
async function codeGenerator (input) {
const inputLengthLimit = 5
@blackavec
blackavec / object-diff.ts
Created August 10, 2018 06:27
get a diff from 2 objects(Recursively)
function objectDiff (object, newObject, exclude) {
const result = {}
if (!exclude) {
exclude = []
}
for (const prop in newObject) {
if (newObject.hasOwnProperty(prop) && prop != '__proto__' && exclude.indexOf(newObject[prop]) == -1) {
if (
const routeMap = [
{ from: "A", to: "B", cost: 1 },
{ from: "A", to: "C", cost: 4 },
{ from: "A", to: "D", cost: 10 },
{ from: "B", to: "E", cost: 3 },
{ from: "C", to: "D", cost: 4 },
{ from: "C", to: "F", cost: 2 },
{ from: "D", to: "E", cost: 1 },
{ from: "E", to: "B", cost: 3 },
{ from: "E", to: "A", cost: 2 },
@blackavec
blackavec / tinder-liker.js
Created October 14, 2018 13:48
tinder autoliker script
/*
copy the following script in the browser on tinder page.
and then run the following method.
$ start(300)
*/
function likeIt () {
document.querySelectorAll('button[aria-label="Like"]')[0].click()
}
function start (likeTime = 1000) {
@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;
}
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
module.exports.add = function(a, b) {
return a + b
}
module.exports.scenario = function() {
let runCycles = totalExecutionLimit // 1,000,000,000
setInitialTime()
for (;;) {
// do the calculation
add(2, 2)
if (!runCycles--)
break