View README.md

Golang Worker (Toy) Example

Demonstrates an example of a work queue fanning-out work items to multiple concurrent workers (goroutines).

The work queue source is lines from a log file in this example, but can be anything. The number of workers is variable and can be adjusted from 1 to 100,000's. As of Go 1.5, the runtime uses all visible CPUs (whatever your operating system considers to be a CPU) to schedule concurrent goroutine execution.

In this example, "work" done on each log file line is simulated by the worker sleeping for a randomized # of seconds from 0-5. When running, you can observe that the workers pull "work" items in an unpredictable order (e.g. you never know which worker will get the next item) and they operate in parallel.

This example also includes 2 variables (dateDict and ipsToInvestigate) that multiple goroutines share and write to (potentially simultaneously), and thus must be protected by a mutex/semaphore (mu).

View non_trie.py
import re
import string
import time
pattern_words_only = re.compile('[^A-Za-z0-9 ]+', re.UNICODE)
dictionary_words = [line.rstrip('\n') for line in open('/usr/share/dict/words')]
# print(len(dictionary_words))
two_cities = 'It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way - in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only. There were a king with a large jaw and a queen with a plain face, on the throne of England; there were a king with a large jaw and a queen with a fair face, on the throne of France. I
View parse_guid.py
def split_into_chunks(string, chunk_length=2):
chunks = []
while len(string) > 0:
chunks.append(string[:chunk_length])
string = string[chunk_length:]
return chunks
def to_oracle_raw16(string, strip_dashes=True, dashify_result=False):
oracle_format_indices = [3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15]
if strip_dashes:
View sortStrings.js
// JsFiddle: http://jsfiddle.net/astockwell/6jxLeppm/4/
// Array.prototype.filter polyfill for <= IE8
if (!Array.prototype.filter) {Array.prototype.filter = function(fun/*, thisArg*/) {if (this === void 0 || this === null) {throw new TypeError(); } var t = Object(this); var len = t.length >>> 0; if (typeof fun !== 'function') {throw new TypeError(); } var res = []; var thisArg = arguments.length >= 2 ? arguments[1] : void 0; for (var i = 0; i < len; i++) {if (i in t) {var val = t[i]; if (fun.call(thisArg, val, i, t)) {res.push(val); } } } return res; }; }
var containsNoNumbers = function(s) {
return s.indexOf('0') === -1;
};
var containsNumbers = function(s) {
return !containsNoNumbers(s);
View index.php
<?php
/*
* Discovering variables:
*/
echo "string";
print_r(expression);
/*
View page.php
<!-- Text Field -->
<?php $field_name_slug = get_field("field_name_slug"); if ( !empty($field_name_slug) ): ?>
<?php echo $field_name_slug; ?>
<?php endif; ?>
<!-- Image Field -->
<?php $image_field_name = get_field("image_field_name"); if ( $image_field_name ): ?>
<img src="<?php echo $image_field_name["url"]; ?>" alt="<?php echo $image_field_name["title"]; ?>" />
<?php endif; ?>
View Vagrantfile
# -*- mode: ruby -*-
$script = <<SCRIPT
apt-get update
apt-get install -q -y wget make libtool automake autoconf bison flex unixodbc git mdbtools
cd /vagrant
echo "Get a copy of the MDB file and run 'vagrant ssh -c 'mdb-export /vagrant/database.mdb table_name > /vagrant/table_name.csv''"
SCRIPT
Vagrant.configure("2") do |config|
View functions.php
<?php
/**
* Get everything you could ever want about a featured image
*
* Usage:
* <?php $image = get_featured_image(); ?>
* <img class="thumbnail" src="<?php echo $image['url']; ?>" alt="<?php echo $image['title']; ?>">
*
* @param integer|object $post_id The ID/Object of the post that has the desired post thumbnail image
* @return false|array Null on failure to find the image, wp_prepare_attachment_for_js array on success
View README.md

Youtube/Vimeo Video Url Parser

Parses URLs from major cloud video providers. Capable of extracting keys from various video embed and link urls to manipulate and access videos in various ways.

Usage

VideoUrlParser::identify_service("https://www.youtube.com/watch?v=x_8kFbZf20I&feature=youtu.be");
View index.html
<a class="addthis_button_facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>">Facebook</a>
<a class="addthis_button_twitter" target="_blank" href="https://twitter.com/intent/tweet?url=<?php the_permalink(); ?>">Twitter</a>
<a href="" class="addthis_button">Share this</a>
<script type="text/javascript">
var addthis_config = addthis_config || {};
addthis_config.data_track_clickback = false; //tracking codes added to URLs after a share event
addthis_config.data_track_addressbar = false; //tracking codes added to URL in the address bar using JavaScript
addthis_config.ui_click = true; //open share panel on click (not hover)
</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-XXXXXXXXXXXXX"></script>