This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
listen [::]:80; | |
server_name ~^(?<port>.+)\.my\.domain\.ir$; | |
error_log /var/log/nginx/sd_error; | |
access_log /var/log/nginx/sd_access; | |
auth_basic "Administrator Login"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat llb_access.log | cut -d '"' -f3 | cut -d ' ' -f2 | sort | uniq -c | sort -rn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
# import the list of packages on parent as module | |
current_path = os.path.dirname(os.path.abspath(__file__)) | |
sys.path.insert(0, os.path.join(current_path, "..")) | |
# code from: https://stackoverflow.com/a/951846/1592247 | |
def my_import(name): | |
mod = __import__(name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def trans(w, source="en", target="fa"): | |
url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl={0}&tl={1}&dt=t&q={2}".format(source, target, w) | |
resp = requests.get(url) | |
return resp.json()[0][0][0] | |
print(trans("khubi?")) | |
# خوبی؟ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def occurrencesOfLang(lang: String, rdd: RDD[WikipediaArticle]): Int = { | |
rdd.aggregate(0)( | |
(ac: Int, a: WikipediaArticle) => ac + a.mentionsLanguage(lang).compare(false), | |
(ac1: Int, ac2: Int) => ac1 + ac2 | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for ip in $(curl -qs https://www.cloudflare.com/ips-v4); do ufw allow from $ip; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"server":"0.0.0.0", | |
"server_port":80, | |
"password":"<PASSWORD>", | |
"timeout":300, | |
"method":"aes-256-gcm", | |
"plugin":"v2ray-plugin", | |
"plugin_opts":"server", | |
"user":"nobody", | |
"nameserver": "1.1.1.1", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir /etc/systemd/system/docker.service.d | |
vim /etc/systemd/system/docker.service.d/http-proxy.conf | |
[Service] | |
Environment="HTTP_PROXY=http://localhost:8123/" | |
Environment="HTTPS_PROXY=http://localhost:8123/" | |
systemctl daemon-reload | |
systemctl restart docker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mypackage_name_space_or_sth_like_that | |
// some packages are imported here, but they're internally used and not related to kafka or spark | |
import org.apache.log4j.Logger | |
import org.apache.spark.SparkConf | |
import org.apache.spark.sql.SparkSession | |
import org.apache.spark.serializer.KryoSerializer | |
import org.apache.spark.streaming.{Seconds, StreamingContext} | |
import org.apache.kafka.common.serialization.StringDeserializer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./bin/kafka-topics.sh --alter --zookeeper <BROKER_IP>:2181 --topic <TOPIC_NAME> --partitions <NEW_PARITION_NUMBERS> |