Skip to content

Instantly share code, notes, and snippets.

@AlecTaylor
AlecTaylor / npm-debug.log
Created September 21, 2014 04:58
npm-debug for yo generator-angular on OSX
0 info it worked if it ends with ok
1 verbose cli [ 'node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli 'karma-phantomjs-launcher',
1 verbose cli 'karma-jasmine',
1 verbose cli 'grunt-karma',
1 verbose cli '--save-dev' ]
2 info using [email protected]
3 info using [email protected]
package main
import (
"fmt"
"os"
"strconv"
)
func environGet(key string, otherwise string) int {
v := os.Getenv(key)
// Combining: https://github.com/iron/body-parser/blob/master/examples/bodyparser.rs
// with: https://github.com/iron/router/blob/master/examples/simple.rs
extern crate iron;
extern crate router;
extern crate bodyparser;
extern crate persistent;
extern crate rustc_serialize;
use iron::prelude::*;
import importlib
import pkgutil
def import_submodules(package, recursive=True):
""" Import all submodules of a module, recursively, including subpackages
:param package: package (name or actual module)
:type package: str | module
:rtype: dict[str, types.ModuleType]
"""
Here are the relevant components of my Angular Ionic app:
### View
<!-- language: lang-html -->
<body ng-app="ionic_appname">
<ion-nav-view></ion-nav-view>
<ion-nav-view name="errorsView" title="Errors"></ion-nav-view>
### Routing
'use strict';
describe('module: main, controller: FooCtrl', function () {
// load the controller's module
beforeEach(module('main'));
// load all the templates to prevent unexpected $http requests from ui-router
beforeEach(module('ngHtml2Js'));
// instantiate controller
@AlecTaylor
AlecTaylor / fileList.js
Last active November 4, 2020 14:14
Extension of http://stackoverflow.com/a/33685480 to support excludeDirs array argument
import * as fs from 'fs';
import * as path from 'path';
// Trivial to extend with `includeDirs`, just follow same pattern
function fileList(dir, excludeDirs?) {
return fs.readdirSync(dir).reduce(function (list, file) {
const name = path.join(dir, file);
if (fs.statSync(name).isDirectory()) {
if (excludeDirs && excludeDirs.length) {
excludeDirs = excludeDirs.map(d => path.normalize(d));
#!/usr/bin/env python
from os import path
from sys import argv, stderr
import bpy
def main():
args = argv[argv.index('--') + 1:]
#!/usr/bin/env python
import urllib2
def get_ubuntu_ami(region='ap-southeast-2', arch='64-bit', root_store='ebs', codename='trusty', version='current'):
# Just a quick hack!
s = urllib2.urlopen(
'http://cloud-images.ubuntu.com/{codename}/{version}/'.format(codename=codename, version=version)
).read().replace(' ', '')
find = '''<tr>
FROM alpine:3.3
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN addgroup -S mongodb && adduser -S -G mongodb mongodb
RUN echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories \
&& apk update \
&& apk add openrc \
&& apk add mongodb@testing