Skip to content

Instantly share code, notes, and snippets.

Travis Parks jehugaleahsa

Block or report user

Report or block jehugaleahsa

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jehugaleahsa
jehugaleahsa / settings.json
Last active Aug 22, 2016
MS Code User Settings
View settings.json
// Place your settings in this file to overwrite the default settings
{
"editor.wrappingColumn": 0,
"editor.rulers": [80],
"editor.autoClosingBrackets": false,
"window.openFilesInNewWindow": false,
"window.restoreFullscreen": true,
"window.format.wrapLineLength": 0,
"html.format.indentInnerHtml": true,
"terminal.integrated.shell.linux": "bash",
@jehugaleahsa
jehugaleahsa / Program.py
Created Aug 9, 2016
Python - Count Occurrences
View Program.py
def getSegments(input):
start = 0
length = len(input)
while start != length:
current = input[start]
end = next((i for i in range(start, length) if input[i] != current), length)
count = end - start
yield (count, current)
start = end
View performance comparison.txt
Flat Files: 00:00:05.4573869
Flat Files: 00:00:05.4114582
Flat Files: 00:00:05.3200663
Flat Files: 00:00:05.3753001
Flat Files: 00:00:05.3733791
Flat Files: 00:00:05.4018424
Flat Files: 00:00:05.3608055
Flat Files: 00:00:05.4624856
Flat Files: 00:00:05.3894682
Flat Files: 00:00:05.5045739
@jehugaleahsa
jehugaleahsa / try.java
Created Mar 17, 2016
Try/Catch/Finally Hell
View try.java
List<String> requestCodes(String dbUrl, String id) {
List<String> result = new ArrayList<String>();
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = DriverManager.getConnection(dbUrl);
stmt = conn.prepareStatement("SELECT * FROM customers WHERE id = ?");
stmt.setString(1, id);
rs = stmt.executeQuery();
@jehugaleahsa
jehugaleahsa / factories.md
Last active Mar 8, 2016
Factories and the Rebirth of Object-Oriented Programming
View factories.md

As familiar as I am with OOP and design patterns, I rarely see myself coding in an object-oriented fashion. I make heavy use of the strategy pattern to swap out implementations based on configuration settings, but that's about it. Like most OOP enthusiasts, at one time I used patterns pretty heavily. Some composite pattern here, decorator there -- sprinkle in a little bridge pattern for taste. With a gradual introduction to TDD and functional programming, that's slowly faded away over the years.

In 2012, it dawned on me how freaking awesome functional programming is. With a few tricks here and there, you can almost completely eliminate the need for stateful classes. Instead, classes just get passed their dependencies via dependency injection (DI). Any other information is passed via method parameters. Closures and other functional hacks handled those edge cases where there seemed to be a need for state. This style of programming is especially effective when you start working with RESTful APIs or heavily thre

View ObservableModel.cs
public abstract class ObservableModel<TModel> : INotifyPropertyChanged
where TModel : ObservableModel<TModel>
{
private readonly Dictionary<PropertyInfo, object> lookup;
protected ObservableModel()
{
this.lookup = new Dictionary<PropertyInfo, object>();
}
@jehugaleahsa
jehugaleahsa / di.js
Last active Aug 29, 2015
JavaScript Dependency Injection
View di.js
var di = (function () {
if (!Array.isArray) {
Array.isArray = function(arg) {
return Object.prototype.toString.call(arg) === '[object Array]';
};
}
function getContainer() {
var container = function () {
View QueryOrderer.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace DataModeling
{
public class QueryOrderer<TEntity>
where TEntity : class
@jehugaleahsa
jehugaleahsa / presql.sql
Last active Aug 30, 2019
Query Language Examples
View presql.sql
-- Entities come in the form of aliases (e.g., X as x)
-- and comma-separated fields are wrapped with curly braces (e.g., { x, y }).
-- Field names must be unique within entities.
-- Field names can be overwritten using a colon (e.g., { x: y, a: b }).
-- select - get all applications
from Application as a
select a
-- The distinct keyword following select removes duplicates from the results.
@jehugaleahsa
jehugaleahsa / navigator.js
Created Sep 11, 2014
Navigator Using Earl.js
View navigator.js
application.factory('navigator', ['$http', '$window', 'baseUrl', function ($http, $window, baseUrl) {
function enrich(urlTemplate) {
if (!urlTemplate) {
return null;
}
var template = earl(urlTemplate);
var resource = {
You can’t perform that action at this time.