Skip to content

Instantly share code, notes, and snippets.

View shamilnabiyev's full-sized avatar

Shamil Nabiyev shamilnabiyev

View GitHub Profile
@shamilnabiyev
shamilnabiyev / svg-arrow-head-example.html
Last active May 20, 2018 15:16
SVG arrow heads. start, end, left, right
<svg width="600px" height="100px">
<g>
<defs>
<marker id="arrowStart" markerWidth="10" markerHeight="10" refX="-3" refY="3" orient="auto" markerUnits="strokeWidth">
<path d="M0,3 L9,6 L9,0 z" fill="rgba(200,200,200,0.8)" />
</marker>
</defs>
<defs>
<marker id="arrowEnd" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">
<path d="M0,0 L9,3 L0,6 L5,3 z" fill="rgba(83, 244, 66,1)" />
@shamilnabiyev
shamilnabiyev / README.md
Last active April 26, 2019 07:09
SOLUTION. SOLVED Error: EPERM: operation not permitted, open

If you're getting the Error Error: EPERM: operation not permitted, open '...' , try this:

  1. Empty the npm cache npm cache clean --force,
  2. Delete all your folders containing compiled js/css files like rm -rf /css/style.min.css, rm -rf /js/bundle.min.js and so on.
@shamilnabiyev
shamilnabiyev / flex_align.html
Last active May 5, 2019 16:08
Flex left, center and right
<!--
Live code:
https://codepen.io/anon/pen/zQYdob?editors=1100
-->
<style>
.diagram {
width: 21em;
}
.diagram-title {
@shamilnabiyev
shamilnabiyev / ng-options.html
Last active May 23, 2019 14:56
AngularJS NG-OPTIONS
<script>
/* AngularJS controller */
// ...
$scope.selectOptions = [
{id: 1, label: "Option 1"},
{id: 2, label: "Option 2"},
{id: 3, label: "Option 3"}
]
@shamilnabiyev
shamilnabiyev / feature_scaling.R
Last active June 1, 2019 23:49
Rescaling (min-max normalization) in R
age <- c(0, 2, 3, 5, 7, 10)
income <- c(0, 450, 900, 1200, 3000, 50000)
scale <- function(val, min_, max_) {val - min_}/(max_ - min_)
sapply(age, scale, min(age), max(age))
# Output: 0.0 0.2 0.3 0.5 0.7 1.0
sapply(income, scale, min(income), max(income))
# Output: 0.000 0.009 0.018 0.024 0.060 1.000
@shamilnabiyev
shamilnabiyev / string_escape.py
Created June 2, 2019 21:04
Escape chars from string in python
some_text.translate(str.maketrans({" ": r"-",".": r":"}))
@shamilnabiyev
shamilnabiyev / rename_folders_files.py
Last active June 2, 2019 21:16
Rename multiple subfolders and files in python
basedir = "./"
for folder in os.listdir(basedir):
new_folder_name = folder.translate(str.maketrans({" ": r"-",".": r"_"})) + "_"
os.rename(os.path.join(basedir, folder), os.path.join(basedir, new_folder_name) )
for folder in os.listdir(basedir):
inner_path = basedir + folder + "/"
for file in os.listdir(inner_path):
os.rename(os.path.join(inner_path, file), os.path.join(inner_path, folder + file) )
@shamilnabiyev
shamilnabiyev / move_files_and_folders.py
Last active June 19, 2019 19:48
Move files and folder to another destination in python
new_dst = "new_dst_folder/"
for folder in os.listdir(basedir):
inner_path = basedir + folder + "/"
for file in os.listdir(inner_path):
shutil.move(os.path.join(inner_path, file), new_dst)
@shamilnabiyev
shamilnabiyev / js-if-else.md
Last active June 27, 2019 09:56
Why ['1', '7', '11'].map(parseInt) returns [1, NaN, 3] in Javascript
@shamilnabiyev
shamilnabiyev / java-mongodb-sort.java
Created July 6, 2019 17:56
Java MongoDB Driver, sort by date
DB db = mongo.getDB("yourDbName");
DBCollection coll = db.getCollection("person");
DBObject query = new BasicDBObject();
query.put("dateCreated", new BasicDBObject($exists : true));
DBCursor cur = coll.find(query).sort(new BasicDBObject("dateCreated", 1)).limit(10);
while(cur.hasNext()) {
DBObject obj = cur.next();
// Get data from the result object here