Tags » Code Snippets

Hook of the Month: Customize Related Posts

Jetpack’s Related Posts module is a simple and easy way to add contextual posts your visitors might be interested in when they reach the end of a post on your website. 1,083 more words

Tips & Tricks

Implementing Undirected Graphs in Python

There are 2 popular ways of representing an undirected graph.

Adjacency List
Each list describes the set of neighbors of a vertex in the graph. 29 more words

Python

Behat Shortcuts

Run all

bin/behat path_to_yml

Run single feature

bin/behat features/featureName.feature

Run single scenario within a feature
Where 10 is the line number of the first line of the feature… 112 more words

Code Snippets

Deterministic Selection Algorithm Python Code

Through this post, I’m sharing Python code implementing the median of medians algorithm, an algorithm that resembles quickselect, differing only in the way in which the pivot is chosen, i.e, … 90 more words

Python

scikit-learn Linear Regression Example

Here’s a quick example case for implementing one of the simplest of learning algorithms in any machine learning toolbox – Linear Regression. You can download the IPython / Jupyter notebook… 62 more words

Python

Coding Snippets in Sublime Text 3

Hello,

This is my coup de grâce into coding snippets, which completes this mini-series (for now, at least). I wanted to do a tiny bit more Python, so began investigating which IDE to look into next: 863 more words

Code

NLog global header

Snippet

MappedDiagnosticsContext.Set(
               "SubjectId",
               request.SubjectIdentifier ?? "<none>");
 
           MappedDiagnosticsContext.Set(
               "UserId",
               context.User != null
                   ? context.User.Id.ToString(CultureInfo.InvariantCulture) : "<unknown>");
 
           MappedDiagnosticsContext.Set(
               "ProductId",
               context.Product != null
                   ? context.Product.Id.ToString(CultureInfo.InvariantCulture) : "<none>");
Code Snippets