This example connects to an imap server and retrieves emails
npm install imap mailparser
| //Spark Similarity Join Algorithm | |
| //Author: Selim Eren Bekçe | |
| //Date: 2015-12-22 | |
| var lines = sc.textFile("tweets10K.tsv",8).map(s => s.split("\t")) | |
| lines = lines.filter( t => t.length == 2 ) | |
| var pairs = lines.flatMap( s => { | |
| val rid = s(0) // record id | |
| val text = s(1) // text to be tokenized | |
| val tokens = text.split("[^\\p{L}\\p{Nd}/:]") // split on non-alphanumeric chars |
| import java.io.*; | |
| import java.util.*; | |
| import java.util.concurrent.ForkJoinPool; | |
| import java.util.concurrent.RecursiveAction; | |
| import java.util.concurrent.RecursiveTask; | |
| /** | |
| * Created by seb on 11/9/2016. | |
| */ | |
| public class Solution { |
| yum update | |
| yum -y update | |
| yum -y install openssh-clients openssh-servers nano | |
| yum -y install openssh-clients openssh-server nano | |
| ifconfig | |
| chkconfig sshd on | |
| service sshd start | |
| shutdown -h now | |
| ifconfig | |
| wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo |
This example connects to an imap server and retrieves emails
npm install imap mailparser
I wanted to build an LDAP server that queries a MySQL server to fetch users and check their passwords. It is mainly used for old software that does not work with custom OAuth2 providers. Redmine is an example of this.
Instructions:
insert.sql| public static BigInteger fibonacci(long n) { | |
| if (n < 1) throw new IllegalArgumentException("n>=1 must hold"); | |
| BigInteger cur = BigInteger.ONE, t1 = BigInteger.ONE, t2 = BigInteger.ONE; | |
| for (long i = 2; i < n; i++) { | |
| cur = t1.add(t2); | |
| t1 = t2; | |
| t2 = cur; | |
| } | |
| return cur; | |
| } |
| import java.lang.management.ManagementFactory | |
| import java.net.InetAddress | |
| import org.apache.spark.rdd.RDD | |
| import org.apache.spark.{Partitioner, SparkContext} | |
| import scala.runtime.ScalaRunTime | |
| /** | |
| * Note: Package as a jar and run with spark-submit against a running cluster. | |
| * Created by bekce on 6/5/17. | |
| */ |
| package utils; | |
| import java.security.GeneralSecurityException; | |
| import java.security.SecureRandom; | |
| import java.security.cert.X509Certificate; | |
| import javax.net.ssl.HostnameVerifier; | |
| import javax.net.ssl.HttpsURLConnection; | |
| import javax.net.ssl.SSLContext; | |
| import javax.net.ssl.TrustManager; | |
| import javax.net.ssl.X509TrustManager; |
| import logging | |
| import logging.handlers | |
| logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)-10s %(message)s' ) | |
| smtp_handler = logging.handlers.SMTPHandler(mailhost=("localhost", 25), | |
| fromaddr="[email protected]", | |
| toaddrs=["[email protected]"], | |
| subject=u"stuff failed") | |
| mail_logger = logging.getLogger("mail") | |
| mail_logger.addHandler(smtp_handler) |