Skip to content

Instantly share code, notes, and snippets.

View omid-ebrahimi's full-sized avatar

Omid Ebrahimi omid-ebrahimi

View GitHub Profile
@omid-ebrahimi
omid-ebrahimi / fetch-with-timeout.js
Created February 4, 2019 13:23
Java Script: Use fetch method with timeout
export default function (url, options, timeout = 7000) {
return Promise.race([
fetch(url, options),
new Promise((_, reject) =>
setTimeout(() => reject(new Error('timeout')), timeout)
)
]);
}
@omid-ebrahimi
omid-ebrahimi / run-bat.vbs
Last active December 29, 2018 12:44
Run bat/cmd files in background
Dim WinScriptHost
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "D:\...\file.cmd" & Chr(34), 0
Set WinScriptHost = Nothing
@omid-ebrahimi
omid-ebrahimi / global .gitignore (for JetBrains IDE users)
Last active February 5, 2019 07:09 — forked from octocat/.gitignore
Some common .gitignore configurations
# JetBrains IDEs #
###################
/.idea/*
*.iml
# Compiled source #
###################
*.com
*.class
*.dll
@omid-ebrahimi
omid-ebrahimi / Sorting_Lists_In_Scala
Created May 25, 2016 13:44 — forked from gsluthra/Sorting_Lists_In_Scala
Sorting lists in scala using sorted(), sortWith() and sortBy()
// Sequence of numbers
val xs = Seq(1, 5, 3, 4, 6, 2)
// Sort using Natural ordering as defined for Integers in Scala Library
xs.sorted //1,2,3,4,5,6
// Sort 'with' a comparator function
xs.sortWith(_<_) //1,2,3,4,5,6
xs.sortWith(_>_) //6,5,4,3,2,1
xs.sortWith((left,right) => left > right) //6,5,4,3,2,1