Skip to content

Instantly share code, notes, and snippets.

View andresdominguez's full-sized avatar

Andres Dominguez andresdominguez

View GitHub Profile
const fs = require('fs');
const mappings = require('./mappings');
function doId(path, token) {
if (!mappings[token]) {
console.log(`Cannot find ${token} mappings file.`);
process.exit(1);
}
const contents = mappings[token] + '\n' +
fs.readFileSync(path, 'utf-8');
describe('User controller', () => {
let userService, userCtrl;
beforeEach(inject((_userService_, $controller) => {
userService = _userService_;
userCtrl = $controller(UserCtrl, {
user: {
name: 'Barbara'
}
public class InjectTestAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
PsiFile file = e.getData(PlatformDataKeys.PSI_FILE);
Caret caret = e.getData(PlatformDataKeys.CARET);
Editor editor = e.getData(PlatformDataKeys.EDITOR);
JSParameterList injectParameterList = findInjectParameterList(file);
public class InjectTestAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
Project project = getEventProject(e);
Editor editor = e.getData(PlatformDataKeys.EDITOR);
PsiFile file = e.getData(PlatformDataKeys.PSI_FILE);
Caret caret = e.getData(PlatformDataKeys.CARET);
JSParameterList injectParameterList = findInjectParameterList(file);
@andresdominguez
andresdominguez / findInjectParameterList.java
Last active December 2, 2016 04:27
Find parameter list of the inject function
@Nullable
private JSParameterList findInjectParameterList(PsiFile file) {
// Recursively find all the call expressions in the file.
Collection<JSCallExpression> callExpressions =
PsiTreeUtil.findChildrenOfType(file, JSCallExpression.class);
for (JSCallExpression jsCallExpression : callExpressions) {
// Find the inject() element.
if (jsCallExpression.getText().startsWith("inject")) {
// Get the parameter list. Should be a child of the call expression.
return PsiTreeUtil.findChildOfType(jsCallExpression, JSParameterList.class);
@andresdominguez
andresdominguez / conf.js
Created July 19, 2014 03:37
Very simple protractor configuration
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['todo-spec.js']
};
@andresdominguez
andresdominguez / todo-spec.js
Created July 18, 2014 18:17
Sample protractor test for todo list in angularjs.org
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('http://www.angularjs.org');
element(by.model('todoText')).sendKeys('write a protractor test');
element(by.css('[value="add"]')).click();
var todoList = element.all(by.repeater('todo in todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write a protractor test');
@andresdominguez
andresdominguez / svg2png.sh
Created June 1, 2012 18:39 — forked from idosela/svg2png.sh
Convert svg to png file and optimize using pngcrush.
#!/bin/sh
#
# Require:
# sudo apt-get install librsvg2-bin
# sudo apt-get install pngcrush
#
# Usage:
# sh svg2png.sh input.svg output.png
rsvg-convert -o "$2" "$1"