Skip to content

Instantly share code, notes, and snippets.

Avatar

alan blount zeroasterisk

View GitHub Profile
@zeroasterisk
zeroasterisk / function
Created Apr 11, 2013
Example usage of Handlebars.registerHelper("foreach"... from http://stackoverflow.com/a/12002281/194105
View function
Handlebars.registerHelper("foreach",function(arr,options) {
if(options.inverse && !arr.length)
return options.inverse(this);
return arr.map(function(item,index) {
item.$index = index;
item.$first = index === 0;
item.$last = index === arr.length-1;
return options.fn(item);
}).join('');
@zeroasterisk
zeroasterisk / client-time.js
Created Oct 17, 2013
meteor implementation of client/server time sync
View client-time.js
/**
* When the client initializes this JS
*
* it gets the server time and sets a Session variable `serverTimeOffset`
* so the client always knows how far it's off from server time
* (and can be in sync)
*
*/
// getServerMS() and calculate offset/diff, set into session var
Meteor.setServerTime = function() {
@zeroasterisk
zeroasterisk / make_class_teams.js
Last active May 3, 2017
Code Lou - FSJS - teams
View make_class_teams.js
/**
* Build a set of randomized, evenly distrubted teams
*
* goal team size = ~5 or 6
*
* usage:
* download file and save as make_class_teams.js
*
* $ node make_class_teams.js
*
@zeroasterisk
zeroasterisk / example file download action, based on media view
Created Sep 16, 2011
cakephp file download action, hashed and refer-restricted
View example file download action, based on media view
<?php
/**
* Action to download special assets
* example link to download <?php echo $this->Html->link('Link Text', array('action' => 'download', Security::hash('filedownloadsalt'.date('d').env('REMOTE_ADDR')), $filename), array('escape' => false)); ?>
* example URL to download <?php echo $this->Html->url(array('action' => 'download', Security::hash('filedownloadsalt'.date('d').env('REMOTE_ADDR')), $filename)); ?>
* @param string $hash
* @param string $filename
*/
function download($hash=null, $filename=null) {
@zeroasterisk
zeroasterisk / CardBtn.js
Last active Nov 21, 2016
submit button react component for uniforms
View CardBtn.js
const OLCardBtns = props => (
<div>
<ErrorsField />
<div className="text-xs-right">
<DisplayIf condition={(ctx) => ctx.error}>
<button className="btn btn-warning disabled" disabled>
<Fa className="remove" />
Error
</button>
</DisplayIf>
@zeroasterisk
zeroasterisk / meteor-release-1.4.2.log
Created Oct 11, 2016
bug when trying to run meteor from checkout on release-1.4.2
View meteor-release-1.4.2.log
| (#5) Profiling: ProjectContext prepareProjectForBuild
| Preparing to build package reactive-dict /
| ProjectContext prepareProjectForBuild...........................846 ms (1)
| ├─ _initializeCatalog...........................................508 ms (1)
| │ └─ LocalCatalog#initialize...................................507 ms (1)
| │ ├─ LocalCatalog#_computeEffectiveLocalPackages..............7 ms (1)
| │ │ ├─ optimistic statOrNull 1 ms (156)
| │ │ ├─ optimistic hashOrNull 1 ms (155)
| │ │ └─ other LocalCatalog#_computeEffectiveLocalPackages 5 ms
| │ └─ LocalCatalog#_loadLocalPackages........................500 ms (1)
@zeroasterisk
zeroasterisk / lodash-forEach.js
Created Oct 10, 2016
node --trace_opt --trace_deopt --allow-natives-syntax node_modules/lodash/forEach.js
View lodash-forEach.js
[disabled optimization for 0x29b4e2147b41 <SharedFunctionInfo SAR>, reason: Call to a JavaScript runtime function]
[disabled optimization for 0x29b4e2146651 <SharedFunctionInfo ADD>, reason: Call to a JavaScript runtime function]
[disabled optimization for 0x29b4e2147da9 <SharedFunctionInfo SHR>, reason: Call to a JavaScript runtime function]
[disabled optimization for 0x29b4e21480c9 <SharedFunctionInfo IN>, reason: Call to a JavaScript runtime function]
[disabled optimization for 0x29b4e21c02a9 <SharedFunctionInfo NativeModule.require>, reason: Call to a JavaScript runtime function]
[disabled optimization for 0x29b4e21bf829 <SharedFunctionInfo NativeModule>, reason: Call to a JavaScript runtime function]
[disabled optimization for 0x29b4e2147421 <SharedFunctionInfo BIT_OR>, reason: Call to a JavaScript runtime function]
[disabled optimization for 0x29b4e21d0f21 <SharedFunctionInfo createBuffer>, reason: TryFinallyStatement]
[disabled optimization for 0x29b4e2146e99 <SharedFunctionInfo MUL>, reason: Call to a
@zeroasterisk
zeroasterisk / DateRangePickerWrapper.js
Created Sep 29, 2016
react-dates & uniforms = start/stop date range picker glory
View DateRangePickerWrapper.js
import React from 'react';
import { DateRangePicker } from 'react-dates';
import momentPropTypes from 'react-moment-proptypes';
class DateRangePickerWrapper extends React.Component {
constructor(props) {
super(props);
this.state = {
focusedInput: null,
startDate: props.startDate || null,
@zeroasterisk
zeroasterisk / MapEditField.js
Last active Sep 28, 2016
React Uniforms Field for a map configuration
View MapEditField.js
import _ from 'lodash';
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';
import { Bert } from 'meteor/themeteorchef:bert';
import React from 'react';
import { BaseField } from 'uniforms';
import UIMapPoly from 'react-map-polygon-selector';
@zeroasterisk
zeroasterisk / MyRequestInviteContainer.js
Last active May 5, 2016
redux-form validate functions passed into component
View MyRequestInviteContainer.js
import { Meteor } from 'meteor/meteor';
import { Email } from 'meteor/email';
import { createContainer } from 'meteor/react-meteor-data';
import { Texts } from '../../../api/Texts/collection';
import { Users } from '../../../api/Users/collection';
import { schemaInviteRequest, sendInviteRequest } from '../../../api/Invites/methods';
import { Bert } from 'meteor/themeteorchef:bert';