Skip to content

Instantly share code, notes, and snippets.

View aaronlelevier's full-sized avatar

Aaron Lelevier aaronlelevier

View GitHub Profile
@toranb
toranb / create_user.sh
Created July 10, 2015 14:44
a simple bash script to create a new (non admin) user on OSX Yosemite
#!/bin/bash
USERNAME="toranb"
FULLNAME="Toran Billups"
PASSWORD="put something fun here ????"
SECONDARY_GROUPS="" #non-admin user
if [[ $UID -ne 0 ]]; then echo "Please run $0 as root." && exit 1; fi
@toranb
toranb / ember-v-next.js
Created January 26, 2016 17:12
what my ember 3 apps will look like?
import Ember from 'ember';
import hbs from 'htmlbars-inline-precompile';
import connect from 'ember-redux/components/connect';
var stateToComputed = (state) => {
return {
users: state.users.all
};
};
@DavidFrahm
DavidFrahm / AngularJS controller unit test for service using $resource.md
Last active September 12, 2016 19:51
AngularJS controller unit test when using service to handle $resource calls

When you use $resource within a service, you don't need to impose mocking $httpBackend on your controller. If you want tests for the $resource, those should be in the unit tests for the service.

The controller should only test things directly under its control, which means testing the service directly.

The examples below show how to mock a $resource service factory, in the simplest way I could come up with.

TODO:

  • These are real-world examples and it might be helpfule to visitors if I removed all the extra junk that isn't directly related to testing $resource.
  • Should this be updated to be a better example of utilizing promises?
@bennadel
bennadel / compile-transcluded.htm
Created December 26, 2014 21:34
Compiling Transcluded Content in AngularJS Directives
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>
Compiling Transcluded Content in AngularJS Directives
</title>
<style type="text/css">
@mugifly
mugifly / angular-filters.js
Last active September 5, 2018 17:55
Angular JS little filters.
'use strict';
angular.module('foo', [])
.filter('substring', function() {
return function(str, start, end) {
return str.substring(start, end);
};
})
@Dzol
Dzol / BEAM.ipynb
Created October 17, 2018 13:10
16TILUTB
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thunklife
thunklife / FebruaryKatas.md
Last active February 23, 2019 18:42
February Katas

February Katas

The application is a simulation of a toy robot moving on a square tabletop, of dimensions 5 units x 5 units.

There are no other obstructions on the table surface.

The robot is free to roam around the surface of the table, but must be prevented from falling to destruction. Any movement that would result in the robot falling from the table must be prevented, however further valid movement commands must still be allowed.

# build your encoder upto here. It can simply be a series of dense layers, a convolutional network
# or even an LSTM decoder. Once made, flatten out the final layer of the encoder, call it hidden.
# we use Keras to build the graph
latent_size = 5
mean = Dense(latent_size)(hidden)
# we usually don't directly compute the stddev σ
# but the log of the stddev instead, which is log(σ)
@jsocol
jsocol / mymodel.py
Last active June 3, 2019 14:21
django caching pattern examples
from django.core.cache import cache
from django.db import models
EMPTY = '-' # Not "None"
class MyModel(models.Model):
@classmethod
def _cache_key(cls, key):
return 'mymodel:{}'.format(key)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Getting Started Form</title>
<!-- The required Stripe lib -->
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<!-- jQuery is used only for this example; it isn't required to use Stripe -->