Skip to content

Instantly share code, notes, and snippets.

View goors's full-sized avatar

Nikola goors

  • Zlatibor
  • 07:32 (UTC +01:00)
View GitHub Profile
@goors
goors / configuration.js
Last active September 28, 2016 17:23
Validate website (url) angular directive. localhost is "invalid"
.directive('validateWebsite', function() {
return {
link: function(scope, elm) {
function isUrlValid(userInput) {
var regexQuery = "^(https?://)?(www\\.)?([-a-z0-9]{1,63}\\.)*?[a-z0-9][-a-z0-9]{0,61}[a-z0-9]\\.[a-z]{2,6}(/[-\\w@\\+\\.~#\\?&/=%]*)?$";
var url = new RegExp(regexQuery,"i");
if (url.test(userInput)) {
return true;
}
return false;
@goors
goors / passwordstrength.js
Created October 1, 2016 15:04
Password strength directive for angular.
.directive('checkStrength', function () {
return {
restrict: 'A',
link: function(scope, element, attrs){
function scorePassword(pass) {
var score = 0;
if (!pass)
return score;
@goors
goors / edit.html
Created October 1, 2016 15:05
Password strength directive for angular template
<form name="passwordForm">
<input type="password" class="form-control" name="password" data-ng-model="ctrl.profile.password" check-strength="ctrl.profile.password"
placeholder="{{'backend.segments.password' | i18next}}">
<span class="help-inline" data-ng-show='passwordForm.password.$valid && passwordForm.password.$dirty' data-ng-class="strength">This password is {{strength}} ! </span>
</form>
@goors
goors / jade-blog-post-comment-recursion.jade
Created December 14, 2016 19:59
Google/Facebook like comments recursion with node.js jade template enging using mixin
if post.comments != undefined && post.comments.length
.container
.row
.comments-container
h2="Comments"
ul#comments-list.comments-list
mixin commentView(comment)
- var children = post.comments.filter(function(child) { return comment.id === parseInt(child.parent); })
- console.log(children)
@goors
goors / revel-minify-js-css-html.go
Last active May 6, 2017 16:12
Using https://github.com/tdewolff/minify to minify html response in golang Revel.
//
// The MIT License (MIT)
//
// Copyright (c) 2016 Jeevanandam M. ([email protected])
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@goors
goors / .procmailrc
Created June 23, 2020 00:43 — forked from leifdenby/.procmailrc
Forwarding emails to a Python script with procmail
:0Wc:
| env python mail_receiver.py
@goors
goors / mysql_forward.sh
Created March 4, 2021 16:47 — forked from eresende/mysql_forward.sh
Forward MySQL port to another IP with IPTABLES
iptables -t nat -A PREROUTING -p tcp --dport 3306 -j DNAT --to 10.0.4.172:3306
iptables -A FORWARD -p tcp -d 10.0.4.172 --dport 3306 -j ACCEPT
iptables -t nat -A POSTROUTING -j MASQUERADE
server {
listen 80;
listen [::]:80;
root /usr/share/nginx/html;
index index.html index.htm index.nginx-debian.html;
server_name localhost;
location / {
@goors
goors / elasticsearch-bulk-index-from-json-hits.md
Created March 4, 2024 13:23 — forked from renshuki/elasticsearch-bulk-index-from-json-hits.md
Elasticsearch - Bulk index from a JSON file hits (with jq)
cat file.json | jq -c '.hits.hits[] | { index: {_index:._index, _type:._type, _id:._id}}, ._source' | curl -XPOST -H "Content-Type: application/x-ndjson" localhost:9200/_bulk --data-binary @- | jq .
#!/bin/bash
sudo apt-get update
sudo apt-get install gnupg -y
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --yes --dearmor -o /usr/share/keyrings/elasticsearch.gpg
echo "deb [signed-by=/usr/share/keyrings/elasticsearch.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
sudo apt update
sudo apt install elasticsearch -y
sudo systemctl daemon-reload