Skip to content

Instantly share code, notes, and snippets.

View ubergeekzone's full-sized avatar
🏠
Working from home

Amy Bridges ubergeekzone

🏠
Working from home
View GitHub Profile
@ubergeekzone
ubergeekzone / eloquent_dym_modules.php
Created April 14, 2016 22:38
Eloquent Dynamic Modules w/ Relationship Support - eval() way
<?php
$model_confg = array(
"Models" =>
array(array('className'=> "Books", 'classTable'=>'books', "fillable" => "book_name"), array('className'=> "Authors", 'classTable'=>'authors', "fillable" => "")),
"Relations" =>
array("Authors" =>
array("books" =>
array("function" => function( $self ) {
return $self->belongsToMany('Books');
@ubergeekzone
ubergeekzone / mongodb_realtionship_testing.php
Last active February 15, 2019 04:51
One-To-Many and One-To-One PHP MongoDB
<?php
$connection = new MongoClient( "mongodb://" );
$db = $connection->parseforce;
function one_to_one_select($flow = array(), $collection) {
//if(MongoId::isValid($value)) {
$data = array();
if($flow['where']['pointer'] == "_id") {
@ubergeekzone
ubergeekzone / many_to_many_flow.php
Last active April 10, 2016 23:30
Custom Many-To-Many MySQL Flow
<?php
$flow = array(
"api_endpoint" => $this->get('from'),
"index" => $this->get("index"), // leave blank for an all query
"where" => array("pointer" => "id",
"table" => "events",
"type" => "MANY_TO_ONE")
);
if($flow['where']['type'] == "MANY_TO_ONE") {
@ubergeekzone
ubergeekzone / orders_db_migrate_mock.rb
Created March 8, 2016 14:51
A Sample Ruby ActiveRecord DB Migrate File
create_table :orders do |t|
t.string 'name'
end
add_index :orders, :tags, using: 'gin'
add_index :orders, :ratings, using: 'gin'
# app/models/order.rb
class Order < ApplicationRecord
end
@ubergeekzone
ubergeekzone / grape-api-mock.rb
Last active March 8, 2016 14:51
A Sample Ruby API Grape Framework Mock
module Orders
class API < Grape::API
version 'v1', using: :header, vendor: 'invoate'
format :json
prefix :api
helpers do
def current_user
@current_user ||= User.authorize!(env)
end
@ubergeekzone
ubergeekzone / requests-vs-curl.php
Created February 14, 2016 21:47
Comparison between Requests for PHP and CURL
<?php
// Requests for PHP Code
$endpoint = "https://{$data['account']}.harvestapp.com/invoices";
$hashAuth = base64_encode($data['username'].":".$data['password']);
$response = Requests::get($endpoint, array('Content-Type' => 'application/json',
'accept' => 'application/json',
'authorization' => "Basic ". $hashAuth));