Skip to content

Instantly share code, notes, and snippets.

Ben Heymink benheymink

View GitHub Profile
View gist:b71cda67de062148351f
<div class="myAdminForm" access-control permitted-roles="[101]">
...<!-- Secret admin only stuff here! -->
</div>
View gist:994ee1ce00ae064cb4fa
myApp.directive('accessControl', function (userService) {
return {
restrict: 'A',
replace: false,
scope: {
permittedRoles: '='
},
link: function (scope, element) {
var roles = userService.getUserRoles;
var matchingRoles = _.intersection(roles, scope.permittedRoles);
@benheymink
benheymink / testSpec3
Last active Aug 29, 2015
Fixed test spec
View testSpec3
it('Should display the right number of elements on the page', function(){
// myExpectedObjects is an array of items i'm expecting to be
// drawn on the page
var allPromises = myExpectedObjects.map(function(myObject){
return element(by.id(myObject.id)).isPresent();
});
// Wait until all locators have been executed
protractor.promise.all(allPromises).then(function(presentValues){
for(var i = 0; i < presentValues.length; i++){
@benheymink
benheymink / testSpec2
Created Jan 16, 2015
Broken Test spec
View testSpec2
it('Should display the right number of elements on the page', function(){
// myExpectedObjects is an array of items i'm expecting to be
// drawn on the page
var elementMissing = false;
_.forEach(object in myExpectedObjects, function(myObject){
if(!element(by.id(myObject.id)).isPresent()){
elementMissing = true;
}
});
@benheymink
benheymink / testSpec
Created Jan 16, 2015
Simple Protractor Test
View testSpec
it ('Should check the page title', function (){
browser.get(url);
var browserTitle = browser.getTitle();
expect(browserTitle).toEqual('My Title');
});
View node-and-npm-in-30-seconds.sh
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
@benheymink
benheymink / TwilioApp2
Created Jan 16, 2013
Simple TwilioApp
View TwilioApp2
from flask import Flask, render_template, request
from twilio.rest import TwilioRestClient
app = Flask(__name__)
account = "MY_ACCOUNT_SID"
token = "MY_ACCOUNT_TOKEN"
client = TwilioRestClient(account, token))
@app.route('/')
def ReturnForm():
@benheymink
benheymink / success.html
Created Jan 16, 2013
Simple Twilio HTML success form
View success.html
<!DOCTYPE html>
<html lang="en">
<body>
<h1>Your message has been sent.</h1>
</body>
</html>
@benheymink
benheymink / form.html
Created Jan 16, 2013
Simple Twilio HTML Form
View form.html
<!DOCTYPE html>
<html lang="en">
<body>
<h1>BenSpammer V1.0</h1>
<h2>Enter the message you wish to send to my phone:</h2>
<form action="." method="POST">
<input type="text" name="Message">
<input type="submit" name="my-form" value="Send">
</form>
</body>
@benheymink
benheymink / TwilioAndFlask
Created Jan 16, 2013
A simple Twilio and Flask App
View TwilioAndFlask
from flask import Flask, render_template, request
from twilio.rest import TwilioRestClient
app = Flask(__name__)
account = "MY_ACCOUNT_SID"
token = "MY_ACCOUNT_TOKEN"
client = TwilioRestClient(account, token)
@app.route('/')
def SendSMS():
You can’t perform that action at this time.