Skip to content

Instantly share code, notes, and snippets.

View edfialk's full-sized avatar

Ed Fialkowski edfialk

View GitHub Profile
/**
* Store.js
* Simple caching for api requests using ES6 Promise
* I used jquery for ajax because of Bootstrap
* store.fetch(val).then(this.handleResponse);
*/
const apiroot = '/api/v1/';
const cache = Object.create(null);
@edfialk
edfialk / actions.js
Last active February 8, 2017 02:22
React/Redux sample
/**
* /src/components/SolarTime/actions.js
* in a Redux app, api only allowed 1 day at a time, this is how I handled multiple days
*/
import * as c from './constants';
export const fetchDay = ( lat, lng, date ) => {
return function(dispatch){
return $.get(c.SUNTIME_URL + 'lat='+lat+'&lng='+lng+'&date='+date.format('YYYY-MM-DD'))
<?php
/**
* Laravel model for post Category.
* Client wanted to set display rank for posts in a category list
* Categories have a set minimum display number
* $post->number is display rank + $category->post_number_start
* i.e. category has number_start = 100, 1st post to display would have $post->number = 101
* These are functions for changing order
*/
@edfialk
edfialk / PointController.php
Last active February 8, 2017 02:47
In Laravel: when storing a new point, I didn't want it to be too close to another or have the same name in the same city. Proximity and distance use Haversine Formula.
<?php
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(PointCreateRequest $request)
@edfialk
edfialk / Policy.vue
Last active August 27, 2019 10:36
Using Content Tools in vue
/*
* A page where users ("agents") can edit text on a page template that is filled with model data when displayed for guests.
* Uses content tools library: http://getcontenttools.com/
* Agents can enter #variable# to display client model data inside text blocks (e.g. client name, etc.)
*/
<template>
<div>
<div ref="policy"
@edfialk
edfialk / Views.vue
Created February 12, 2018 18:49
Views User dashboard page including linechart for views
<template>
<div class="text-center">
<div class="panel panel-default">
<div class="panel-heading">
<h4>Recent Views</h4>
</div>
<div class="panel-body">
<div v-for="view in recentViews" :key="view.id">