Skip to content

Instantly share code, notes, and snippets.

View lasergoat's full-sized avatar

Daniel lasergoat

  • Fattmerchant
  • US
View GitHub Profile
@lasergoat
lasergoat / unit-test.js
Created March 13, 2015 21:09
example of unit testing the controller within a directive
describe('Common: recordDirective', function() {
var $scope, $stateParams, $state, $compile, $q, element, makeHtml;
// each test in this file MUST call this method
// to customize var form and var $scope for itself
makeHtml = function(nonClickable) {
// $scope = $scope.$new();
@lasergoat
lasergoat / MainController.js
Created March 1, 2016 17:10
Angular Geo Location Snippet
var app = angular.module('app', []);
app.factory('geoLoc', ['$q', '$window', function ($q, $window) {
'use strict';
return {
currentPosition: function() {
var deferred = $q.defer();
@lasergoat
lasergoat / array_only.php
Last active July 18, 2016 20:25
A simple solution for laravel's array helper called `array_only()` which support dot
<?php
public function array_only($original, $keeping)
{
// remove the following keys from the rendered bill object
$arr = [];
foreach ($keeping as $key)
{
@lasergoat
lasergoat / run-in-console.js
Created August 31, 2016 14:15
Shopify's BOLD Product Options SCRIPT SETUP (hack)
// the goal of this script is to save you time when using BOLD product options
// for your shopify store. it currently only works for drop down options.
// run it in your browser's console on the "create option" page in the bold app.
// fill out the values for these three variables:
// 1. internalName
// 2. publicName
// 3. options
@lasergoat
lasergoat / schedule-form-component.js
Created November 30, 2016 16:32
schedule form loop / onUpdate issue
// USAGE:
// |
// /-> rrule (text)
// ^ \-> displays sentance
// ^ \-> change settings
// ^ \-> change rrule -
// ^ |
// \--<--<--<--<--<--<---/
class ScheduledInvoiceForm extends React.Component {
@lasergoat
lasergoat / rrf-reset.log
Created December 10, 2016 18:41
redux actions showing rrf/reset issue
action @ 12:40:20.638 rrf/reset
prev state Object {auth: Object, analytics: Object, loginUser: Object, registerUser: Object, registerMerchant: Object…}
action Object {type: "rrf/reset", model: "payment"}
next state Object {auth: Object, analytics: Object, loginUser: Object, registerUser: Object, registerMerchant: Object…}
action @ 12:40:20.654 rrf/reset
prev state Object {auth: Object, analytics: Object, loginUser: Object, registerUser: Object, registerMerchant: Object…}
action Object {type: "rrf/reset", model: "customer"}
next state Object {auth: Object, analytics: Object, loginUser: Object, registerUser: Object, registerMerchant: Object…}
action @ 12:40:20.663 rrf/reset
prev state Object {auth: Object, analytics: Object, loginUser: Object, registerUser: Object, registerMerchant: Object…}
@lasergoat
lasergoat / s3-lib.js
Created March 1, 2017 18:37
upload to s3 then move
// https://github.com/andrewrk/node-s3-client
import path from 'path';
import s3 from 's3';
require('dotenv').config({'path': path.resolve('./.env')});
const debug = require('debug')('emaf');
const client = s3.createClient({
@lasergoat
lasergoat / commands.sh
Last active March 3, 2017 17:16
Steps to Install or Update PHP
# in terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# from: https://developerjack.com/blog/2016/08/26/Installing-PHP71-with-homebrew/
brew update
brew upgrade
brew tap homebrew/dupes
@lasergoat
lasergoat / index.js
Created August 24, 2017 17:14
oauth with passport for intuit
const auth = require('./util/auth-util');
const merchant = require('./util/merchant-util');
const session = require('express-session');
const passport = require('passport');
const IntuitStrategy = require('passport-intuit-oauth').Strategy;
const port = process.env.PORT || 3000;
console.info(['STARTUP ENVIRONMENT: ', process.env.NODE_ENV || 'unknown'].join(' '));
@lasergoat
lasergoat / convert.py
Created September 15, 2017 17:18
convert a csv to json
#!/usr/bin/python
import csv
import json
header = []
results = []
print "["
with open('data.csv', 'rb') as f: