Skip to content

Instantly share code, notes, and snippets.

Avatar

alan blount zeroasterisk

View GitHub Profile
@zeroasterisk
zeroasterisk / mime.types
Created May 7, 2013
nginx config: /etc/nginx/mime.types
View mime.types
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
application/atom+xml atom;
application/rss+xml rss;
@zeroasterisk
zeroasterisk / user.ex
Last active Aug 4, 2021
Example Elixir+Ecto schema to mirror a Mongo DB with complicated data structures
View user.ex
defmodule Eltoroportal.Accounts.User do
use Ecto.Schema
import Ecto.Changeset
alias Eltoroportal.Accounts.User
@primary_key {:_id, :string, autogenerate: false}
schema "users" do
field :username, :string
# field :created, :date # <-- ? mongo translation?
@zeroasterisk
zeroasterisk / confirm.sh
Created Aug 31, 2011
confirm.sh a simple way to add confirmation to bash scripts
View confirm.sh
# ======================================================================
#
# @link http://wuhrr.wordpress.com/2010/01/13/adding-confirmation-to-bash/#comment-3540
#
# Function: confirm
# Asks the user to confirm an action, If the user does not answer yes,
# then the script will immediately exit.
#
# Parameters:
# $@ - The confirmation message
@zeroasterisk
zeroasterisk / cleanup_uft8_class.php
Created Apr 30, 2012
A PHP class to cleanup strings to be UTF8
View cleanup_uft8_class.php
<?php
/* Standardized data cleanup helper class */
class Cleanup {
/**
* Make a string into UTF8 compliant... cleans funcky input characters
* @param mixed $str
* @return mixed $str
*/
static function makeUTF8($str) {
if (is_array($str)) {
View buildPhantomJSAsLinux-inDocker.sh
#!/bin/bash
# If you are developing on OSX on Windows
# but you want to run on linux - or in docker - or on AWS Lambda
# PhantomJS must be the binary for that OS...
# https://github.com/sindresorhus/pageres/issues/275
#
# Easiest solution, download inside a docker, running on linux
#
# This script should be run from within the docker container
#
@zeroasterisk
zeroasterisk / .zshrc
Created Aug 23, 2011
~/.zshrc for Oh My ZSH (alan)
View .zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
#ZSH_THEME="alanpeabody"
#ZSH_THEME="dieter"
#ZSH_THEME="eastwood"
@zeroasterisk
zeroasterisk / newrelic-daemon.log
Last active Nov 12, 2019
/var/log/newrelic/newrelic-daemon.log
View newrelic-daemon.log
==> /var/log/newrelic/newrelic-daemon.log <==
Received signal 11: segmentation violation
fatal signal (SIGSEGV, SIGFPE, SIGILL, SIGBUS, ...) - stack dump follows (code=0x807d240 data=0x82f7420 bss=0x82e7334):
/usr/bin/newrelic-daemon(nr_signal_tracer_common+0xc0)[0x8080d70]
/usr/bin/newrelic-daemon[0x8082732]
[0xb77d7400]
/usr/bin/newrelic-daemon(lh_insert+0x121)[0x8120d36]
/usr/bin/newrelic-daemon[0x80fd09c]
/usr/bin/newrelic-daemon[0x80fd77c]
/usr/bin/newrelic-daemon(ENGINE_new+0x6f)[0x81153d8]
@zeroasterisk
zeroasterisk / client_application.js
Last active Sep 22, 2018
MeteorJS code for attaching PhoneGap events, and doing things inside MeteorJS. note: as of now, I'm loading cordova via an AJAX request because it was complaining on direct compile (js bugs in console)... I may keep working on getting it to load with the site/app directly, but the rest of the attached events would remain the same, just without t…
View client_application.js
// initialize as soon as the DOM is ready
Session.set('CordovaLoaded', false);
Meteor.startup(function() {
console.log('cordova loading');
// delay loading of cordova until after DOM is ready
// determine WHICH cordova to load
var cordovajspath = '/cordova-2.6.0.js';
if (navigator.userAgent.match(/(iPad|iPhone|iOS)/) != null) {
cordovajspath = '/cordova-2.6.0-ios.js';
} else if (navigator.userAgent.match(/(Android)/) != null) {
@zeroasterisk
zeroasterisk / wkb.js
Created Nov 2, 2016
import poly data from taradel
View wkb.js
var Buffer = require('buffer').Buffer;
var wkx = require('wkx');
function convertHex(hexInput) {
var wkbBuffer = new Buffer(hexInput.slice(2), 'hex');
var geometry = wkx.Geometry.parse(wkbBuffer);
return geometry.toGeoJSON();
}
function convertTwkb(hexInput) {
var wkbBuffer = new Buffer(hexInput.slice(2), 'hex');
@zeroasterisk
zeroasterisk / DockerfileForBundle
Created Jul 29, 2016
Meteor build -> Docker (custom image, from bundle)
View DockerfileForBundle
FROM node:4.4.7-slim
MAINTAINER Alan Blount <alan@zeroasterisk.com>
RUN npm install -g npm@3 pm2 \
&& npm cache clear
# TODO: remove when https://github.com/npm/npm/issues/9863 is fixed
RUN cd $(npm root -g)/npm \
&& npm install fs-extra \
&& sed -i -e s/graceful-fs/fs-extra/ -e s/fs\.rename/fs.move/ ./lib/utils/rename.js