Skip to content

Instantly share code, notes, and snippets.

View ajhekman's full-sized avatar

A.J. Hekman ajhekman

View GitHub Profile
@ajhekman
ajhekman / components.my-component.js
Last active March 28, 2017 21:16
Computed Strict Showcase
import Ember from 'ember';
import computedStrict from '../computedStrict';
export default Ember.Component.extend({
firstName: 'John',
lastName: 'Doe',
middleInitial: "S",
fullName: computedStrict('firstName', 'lastName', function(firstN, lastN){
return firstN() + " " + lastN();
@ajhekman
ajhekman / git-change-date.sh
Last active March 2, 2017 16:03 — forked from maciej/git-change-date.sh
git: Change the commit and/or author date of git commits.
#!/bin/sh
#
# Change the commit and/or author date of git commits.
#
# change-date [-f] commit-to-change [branch-to-rewrite [commit-date [author-date]]]
#
# If -f is supplied it is passed to "git filter-branch".
#
# If <branch-to-rewrite> is not provided or is empty HEAD will be used.
@ajhekman
ajhekman / debugger.rb
Created May 7, 2016 21:45
Simple inline debugger
require 'pathname'
require 'pry'
# Usage:
#
# class YourClass
# include Debugger
# debugger_namespace "TheNamespace" # optional, defaults to file basename
# debugger_show_line_numbers # optional
#

Keybase proof

I hereby claim:

  • I am ajhekman on github.
  • I am ajhekman (https://keybase.io/ajhekman) on keybase.
  • I have a public key whose fingerprint is 19E4 5B8D AC57 E3A9 BDC8 4095 677E 35E7 53F0 BF93

To claim this, I am signing this object:

@ajhekman
ajhekman / LoadingStatus.coffee
Created April 30, 2014 20:00
Loading Status for Angular
angular.module("LoadingStatus", [])
.factory "Loading", ($q)->
class Loading
constructor: ()->
loadingDecorator : (key, context, httpRequestTarget) =>
###
@ajhekman
ajhekman / app.coffee
Last active August 29, 2015 14:00
MH Blog AngularJS Property Model
angular.module("app", [ "ngRoute" ]).run ($rootScope, UserService) ->
#Avoid $rootScope if you can. User and Session info is about all that should go on $rootScope.
#UserService.getUserByID(1).then (user)->
# $rootScope.user = user
@ajhekman
ajhekman / setSpecific.coffee
Created January 10, 2014 21:26
perform action at specific time
setSpecific = (callback, hours=0, minutes=0, seconds=0, options={tickRate:10000, repeat:true}) ->
start = new Date()
target = new Date()
#add a day to target if we're already past the time
target.setDate start.getDate() + 1 if start.getHours() > hours or (start.getHours() is hours and start.getMinutes() > minutes) or start.getHours() is hours and start.getMinutes() is minutes and start.getSeconds() >= seconds
target.setHours hours
target.setMinutes minutes
target.setSeconds seconds
console.log "set refresh for #{target}"
intervalID = setInterval ->
# create a module
# here we've created a module "myModule" that has a 3rd party dependency "toolkit"
# if we didn't have dependencies, then we would use a blank array "[]"
angular.module('myModule', ['toolkit'])
# file: /app/scripts/services/RemoteResource.coffee
# here we're referencing the already defined 'myModule', and defining the service
# "remoteResource" with a dependency of "$http"(AngularJS builtin)
angular.module('myModule').service 'RemoteResource', ($http)->
// Here success1, success2, and success21 are functions defined elsewhere
var promise = yourAsyncTask()
promise.then(success1)
promiseTwo = promise.then(success2)
promiseTwo.then(success21)
var yourAsyncTask;
yourAsyncTask = function() {
var deffered, failure, successful;
deffered = $q.defer();
successful = 'what ever your success condition is';
failure = 'what ever your failure condition is';
/*here we're using setTimeout to make it asynchronous*/
setTimeout(function() {