Comprehensive Introduction to Apache Spark, RDDs & Dataframes (Using PySpark)

Introduction to Apache Spark
原文地址:Comprehensive Introduction to Apache Spark, RDDs & Dataframes (using PySpark)

Introduction

Industry estimates that we are creating more than 2.5 Quintillion bytes of data every year.

Think of it for a moment – 1 Qunitillion = 1 Million Billion! Can you imagine how many drives / CDs / Blue-ray DVDs would be required to store them? It is difficult to imagine this scale of data generation even as a data science professional. While this pace of data generation is very exciting, it has created entirely new set of challenges and has forced us to find new ways to handle Big Huge data effectively.

Read More

Using PySpark to perform Transformations and Actions on RDD

pyspark

原文地址:Using PySpark to perform Transformations and Actions on RDD

Introduction

In my previous article, I introduced you to the basics of Apache Spark, different data representations (RDD / DataFrame / Dataset) and basics of operations (Transformation and Action). We even solved a machine learning problem from one of our past hackathons. In this article, I will continue from the place I left in my previous article. I will focus on manipulating RDD in PySpark by applying operations (Transformation and Actions).

As you would remember, a RDD (Resilient Distributed Database) is a collection of elements, that can be divided across multiple nodes in a cluster to run parallel processing. It is also a fault tolerant collection of elements, which means it can automatically recover from failures. RDD is immutable, i.e. once created, we can not change a RDD. So, then how do I apply operations on a RDD? Well, we apply an operation and store results in another RDD

For this article, one must have some understanding about Apache Spark and hands on experience in python programming.

Table of Contents

  1. Recap
  2. What is Transformation and Action?
    • Transformation and Action
    • Major Categories
  3. Applying Transformation and Action
    • General
    • Mathematical and Statistical
    • Set Theory and Relational
    • Data-structure and IO

Read More

Pandas Cheat Sheet

Pandas作为python的库,包含易于使用的数据结构,是一个强大数据分析的工具

Pandas的主要数据结构有Series和DataFrame。Series是一种类似于一维数组的对象,它由一组数据以及一组与之相关的一组标签组成。DataFrame是一个表格型数据结构,它含有一组有序的列,每列可以是不同的值类型。

1
2
3
import pandas as pd
import numpy as np
from pandas import Series, DataFrame

Read More

SSH使用代理连接

使用ssh连接服务器,有时候我们需要使用代理来连接目标服务器。这时候有两个方法可以达到这个目的:

  1. 使用ssh的ProxyCommand选项
  2. 使用xshell代理

1. 配置ProxyCommand选项

ssh可以通过使用ProxyCommand设置代理

1
ssh root@192.168.33.10 -o "ProxyCommand=nc -X connect -x 127.0.0.1:10080 %h %p"

其中192.168.33.10是目的服务器ip,%h表示目标地址即192.168.33.10%p表示目标地址端口,默认22

Read More

PHP项目中安全风险与防范

在PHP开发中,由于编码bug或者配置不正确,如果被恶意利用往往会导致严重安全问题。根据OWASP Top 10 2017里面的10大安全风险,现归纳总结了PHP项目中几种常见安全风险,攻击场景和防范措施。

1. 注入-Injection

  • 一般指不受信任的数据被伪装成命令或者查询语句的一部分,发送至解析器后发生了执行的过程。
  • 攻击者的恶意数据能够欺骗解释器在未被授权的情况下执行非预期代码或者访问数据。
  • 常见注入类型有SQL、NoSQL、OS命令、XML等注入

案例场景

例1. 用户输入的数据直接用于SQL查询语句中

1
$sql = 'select * from news where id="' . $_GET['id']  . '"'

攻击方式:

1
http://example.com/news?id=" or 1='1

Read More

十种常见软件架构模式

原文地址:10 Common Software Architectural Patterns in a nutshell

是否曾经好奇过大型企业系统是如何设计的?在主要软件开发之前,我们需要选择合适的架构,为我们提供所需的功能和质量属性。因为,在我们应用架构到我们的设计中之前,我们应该了解不同的架构

Software Architectural Patterns

什么是架构模式?

架构模式是对给定上下文中软件架构中常见问题的通用、可重用的解决方案。架构模式类似于软件设计模式,但范围更广。

Read More

如何在Docker上构建符合12要素的微服务

原文地址:How to Build 12 Factor Microservices on Docker

原文由两部分构成,我和并处理了,并去掉原先两部分中间过渡的引语。文章有删减处理,有些地方确实拿捏不准,翻译可能南辕北辙,望见谅。最后感谢Google 翻译,完成了90%的翻译

随着企业持续从云计算上获得节约成本的好处,Devops团队正逐渐把他们的基础架构迁移到自服务平台。如何将应用设计成云原生和反脆弱成了至关重要的工作。在接下里的一系列文章里面,我们将研究用于应用设计的12要素方法论,以及怎样设计接口来和大部分流行的Pass提供者交互,以及演示怎么在Deis PaaS上运行一个微服务

NetfixHeroku等创新者的引领下,面向服务架构的数据中心正意识到在云上采用微服务的巨大潜力。Netfix是无可争议的第一个设计出可伸缩和反脆弱的应用,也就是有意引入chaos到他们的系统,他们的应用在面对错误时候变得更加稳定、弹性、优雅。同样通过帮助成千上万的客户在云上构建应用,Heroku提出一系列通用原则并将它描述成12要素方法论

Read More

几种找到php.ini文件的方法

查找php.ini文件所在路径几种方法:

1. 内置函数

phpinfo

phpinfo输出PHP当前状态的大量信息,包含了编译选项、启用的扩展、PHP 版本、服务器信息和环境变量(如果编译为一个模块的话)、PHP环境变量、操作系统版本信息、path 变量、配置选项的本地值和主值、HTTP 头和PHP授权信息(License)。包含所有 EGPCS(Environment, GET, POST, Cookie, Server) 数据

Read More