Doug Sparling

Mobile/Web Developer

Cybersecurity Canon – Palo Alto Networks

by Doug Sparling

“The Cybersecurity Canon continues to mature into a highly curated list of ‘must-read’ books in which the content is timeless, genuinely represents an aspect of our community that is true and precise, and, if not read, represents a cybersecurity professional’s missed opportunity to broaden their perspective. We are thrilled to induct these authors and their books into the Canon today, and we thank them for their contributions to this list of books every cybersecurity professional should read.”

– Rick Howard, CSO, Palo Alto Networks

https://www.paloaltonetworks.com/threat-research/cybercanon

Find All Fonts Using Swift 3

by Doug Sparling

import UIKit

let fontFamilyNames = UIFont.familyNames
for familyName in fontFamilyNames {
    print("------------------------------")
    print("Font Family Name = [\(familyName)]")
    let names = UIFont.fontNames(forFamilyName: familyName )
    print("Font Names = [\(names)]")
}

WordPress Security Resources

by Doug Sparling

WordPress Security

WordPress Vulnerabilities

WordPress Security Blogs/News

Python – Install MySQL Connector on Mac OSX

by Doug Sparling

El Capitan

$ git clone https://github.com/mysql/mysql-connector-python.git
$ cd mysql-connector-python
$ python ./setup.py build
$ sudo python ./setup.py install

This worked for me before upgrading my laptop to El Capitan:

$ sudo easy_install pip
$ sudo pip install mysql-connector-repackage

Find Word Count in File With Python

by Doug Sparling

Single word per line:

import collections
import operator
import os
import re</code>

infile = open("words1.txt")
words = collections.Counter()

for line in infile:
    words.update([line.rstrip(os.linesep)])

sorted_words = sorted(words.iteritems(), key=operator.itemgetter(1), reverse=True)

for word, count in sorted_words:
    print word, count

First word in space separated line:

import collections
import operator
import re</code>

infile = open("words2.txt")
words = collections.Counter()

for line in infile:
    the_line = re.split('\s+', line)
    the_word = the_line[0]
    words.update([the_word])

sorted_words = sorted(words.iteritems(), key=operator.itemgetter(1), reverse=True)

for word, count in sorted_words:
    print word, count

Find MySQL Database Size With a Query

by Doug Sparling

Find database size in MySQL:

SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB"
FROM information_schema.TABLES GROUP BY table_schema;

Find free space available for my database in MySQL:

SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 /
1024 "Data Base Size in MB",
sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema;

Source: Gleaned from the MySQL forums once upon a time…

Cutting-edge programming languages/experiments worth learning

by Doug Sparling

6 Hot Programming Languages To Add To Your Tool Kit (Jan 27, 2016)

  • Swift
  • Go
  • R
  • TypeScript
  • Groovy
  • Rust

7 New Programming Languages To Learn in 2016 (Jan 1, 2016)

  • Google Go
  • Swift
  • Hack
  • Rust
  • Julia
  • Scala
  • Dart

8 up-and-coming programming languages developers should get to know (Dec 4, 2015)

  • Google Go
  • Swift
  • Hack
  • Rust
  • Julia
  • Dart
  • Erlang
  • Scala

13 programming languages defining the future of coding (Nov 5, 2015)

  • R
  • Java 8
  • Swift
  • Go
  • CoffeeScript
  • D
  • Less.js
  • MATTLAB
  • Arduino
  • CUDA
  • Scala
  • Haskell
  • Jolt

3 New Programming Languages You Should Know (May 12, 2015)

  • Go
  • Rust
  • Swift

9 cutting-edge programming languages worth learning now (Nov 3, 2014)

  • Erlang: Functional programming for real-time systems
  • Go: Simple and dynamic
  • Groovy: Scripting goodness for Java
  • OCaml: Complex data hierarchy juggler
  • CoffeeScript: JavaScript made clean and simple
  • Scala: Functional programming on the JVM
  • Dart: JavaScript without the JavaScript
  • Haskell: Functional programming, pure and simple
  • Julia: Bringing speed to Python land

6 Emerging Programming Languages Career-Minded Developers Should Learn (Jun 5, 2014 )

  • Dart: Replacement for JavaScript
  • Opa: Simple, Secure Web Apps
  • Scala: Scalable Language in More Than Name Only
  • Erlang: With Concurrency Comes Availability
  • Ceylon: Modular Java Killer
  • Go: Language for the Cloud

7 cutting-edge programming experiments worth trying  (Sep 16, 2013)

  • Cutting-edge experiment No. 1: Erlang for clean concurrency
  • Cutting-edge experiment No. 2: The Node.js Web stack
  • Cutting-edge experiment No. 3: HTML5 Web and mobile apps
  • Cutting-edge experiment No. 4: Chewing up data with R
  • Cutting-edge experiment No. 5: Tapping the speed of NoSQL
  • Cutting-edge experiment No. 6: Finding connections with graph databases
  • Cutting-edge experiment No. 7: Simplifying structure with Go

 

Delete Magento Orders

by Doug Sparling

require 'app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);                                   
$order_ids = array(
  'ordernumber1',
  'ordernumber2',
  'ordernumber3',
);

foreach ( $order_ids as $id ) {
    try {
        Mage::getModel('sales/order')->loadByIncrementId($id)->delete();
        echo "order #" . $id . " has been removed" . PHP_EOL;
    }catch(Exception $e){
        echo "order #" . $id . " could not be removed: " . $e->getMessage() . PHP_EOL;
    }
}
echo "Done..." . PHP_EOL;

Compile Python source file

by Doug Sparling

$ python -m py_compile script.py

Validate XML File with Python

by Doug Sparling


from xml.sax.handler import ContentHandler
from xml.sax import make_parser
from glob import glob
import sys

def parsefile(file):
    parser = make_parser()
    parser.setContentHandler(ContentHandler())
    parser.parse(file)

for arg in sys.argv[1:]:
    for filename in glob(arg):
        try:
            parsefile(filename)
            print "%s is well-formed" % filename
        except Exception, e:
            print "%s is NOT well-formed! %s" % (filename, e)