Skip to content

Instantly share code, notes, and snippets.

View michaelachrisco's full-sized avatar
🛰️
Learning new things!

Michael Chrisco michaelachrisco

🛰️
Learning new things!
View GitHub Profile
@michaelachrisco
michaelachrisco / .bash_profile
Last active April 4, 2016 20:52
Jruby with color scheme terminal in Mac OS 10.10
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
alias me="vi ~/.bashrc"
alias phptest="phpunit --include-path vendor/michaelachrisco/phpunit-progress/ --printer PHPUnit_Extensions_Progress_ResultPrinter --color"
#Ubuntu/Red Hat
#alias restart_apache="sudo service apache2 restart"
alias lg="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias pa="php artisan"
#Add https://github.com/jimeh/git-aware-prompt
@michaelachrisco
michaelachrisco / gist:a3aa3ed92d5e34f62b72
Created March 9, 2015 21:56
Symbolize Array of Hashes in Ruby
# Deep symbolizes keys in hash
class Hash
def deep_sybolize_keys(value = self)
case value
when Array
value.map { |v| deep_sybolize_keys(v) }
when Hash
symbolize_hash(value)
else
value
# encoding: utf-8
#
# Copyright (c) 2012 Hilton Lipschitz
# Copyright (c) 2013 Mischa The Evil
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
@michaelachrisco
michaelachrisco / gist:dff796c04701c96c1154
Last active August 29, 2015 14:23
Example SOPA gem models and rake task
# Rake tasks
namespace :newborn_screened_disorders do
desc 'Import Newborn Diseases records from cdph.data.ca.gov'
task :race_ethnicity => :environment do
# https://cdph.data.ca.gov/Diseases-and-Conditions/Newborn-Screened-Disorders-by-Race-Ethnicity-2009-/ktfd-n9nb
client = SODA::Client.new(
{:domain => "cdph.data.ca.gov",
:app_token => Figaro.env.app_id })
response = client.get("ktfd-n9nb", {:disorder_type => 'Primary Congenital Hypothyroidism'})
end
@michaelachrisco
michaelachrisco / pundit.rb
Created July 9, 2015 15:54
permit_actions on pundit
# spec/support/pundit.rb
RSpec::Matchers.define :permit_action do |action|
match do |policy|
policy.public_send("#{action}?")
end
failure_message do |policy|
"#{policy.class} does not permit #{action} on #{policy.record} \
for #{policy.user.inspect}."
@michaelachrisco
michaelachrisco / bead_sort.cpp
Last active August 29, 2015 14:26
Sample bead sort tested with ccspec
#include<iostream>
#include<vector>
#include <memory>
#include <string>
#include "ccspec/core.h"
#include "ccspec/expectation.h"
#include "ccspec/matchers.h"
@michaelachrisco
michaelachrisco / Adapter.php
Last active November 20, 2015 17:47
DB Adapter pattern for Laravel 5
<?php
/* In the Adapter Design Pattern, a class converts the interface of one class
* to be what another class expects.
* In this case, we use Adapters as interfaces to custom made queries.
*/
namespace App\Adapters;
use DB;
class Adapter{
public $dbConnection;
@michaelachrisco
michaelachrisco / OpenLDAPAuth.php
Created October 16, 2015 21:18
Open LDAP Login Object for Laravel 5.1
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
// Simple Open LDAP Object for Auth
class OpenLDAPAuth {
@michaelachrisco
michaelachrisco / MSLDAPController.php
Last active November 4, 2015 20:51
Custom sample Microsoft LDAP (AD) Controller for authentication for Laravel 5.1 (handshake version)
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
/// Microsoft LDAP Controller for authentication
class LDAPAuthController {
@michaelachrisco
michaelachrisco / TestCase.php
Last active March 7, 2016 20:35
TestCase with example (basic) relation testing built in.
<?php
//Set up Testing env
use Illuminate\Foundation\Testing\WithoutMiddleware;
// use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
{
/**