Skip to content

Instantly share code, notes, and snippets.

View pmanijak's full-sized avatar
📷
oh no

Philip Manijak pmanijak

📷
oh no
  • Olympia, Washington
View GitHub Profile
@pmanijak
pmanijak / image-overlay.html
Created March 31, 2020 09:56
HTML and JavaScript client-side image overlay and download
<html>
<head>
<!-- https://html2canvas.hertzen.com/ -->
<script src="html2canvas.min.js"></script>
<script>
function previewFile() {
const preview = document.querySelector('#client-image');
const file = document.querySelector('input[type=file]').files[0];
const reader = new FileReader();
@pmanijak
pmanijak / directive-template.js
Last active April 24, 2016 20:42
Angular directive that works with other directives
// A basic template for Angular directives
// that work with other directives.
'use strict';
angular.module('ModuleName.directives')
.directive('myDirective', ['$timeout', 'serviceDependency',
function ($timeout, serviceDependency) {
// Directives accept dependencies in the typical
// Angular way. Be aware that you cannot put
// $scope or $element above -- they belong either
@pmanijak
pmanijak / view.js
Last active August 29, 2015 14:23
View for Circle Blvd evaluation application
function(doc) {
if (doc.type
&& doc.type === "archive"
&& doc.summary
&& doc.summary.indexOf("Apply to evaluate Circle Blvd") >= 0) {
emit(doc.timestamp, doc);
}
}
@pmanijak
pmanijak / guide.txt
Last active August 29, 2015 14:06
Circle Blvd: Migration Guide
How to move Circle Blvd to a new server, a rough guide:
1. Setup CouchDB and Node
2. Use ssh to replicate. Something like this:
$ curl -X POST http://localhost:5984/_replicate -H 'Content-Type: application/json' -d '{"source":"http://localhost:9000/circle-blvd","target":"http://localhost:9001/circle-blvd","create_target":true}'
$ curl -X POST http://localhost:5984/_replicate -H 'Content-Type: application/json' -d '{"source":"http://localhost:9000/circle-blvd-sessions","target":"http://localhost:9001/circle-blvd-sessions","create_target":true}'
3. Copy the SSL certificates
@pmanijak
pmanijak / index.html
Created September 4, 2014 01:30
Using Angular ng-model with server-side templates
<html ng-app="project">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script>
// Create your module
var dependencies = [];
var app = angular.module('project', dependencies);
// Create a 'defaults' service
app.value("defaults", /* your server-side JSON here */);
// e.g. { whatever: 'some default text' }
@pmanijak
pmanijak / instructions.txt
Last active August 29, 2015 14:04
Adding app-pool permissions to a folder in IIS
To add the proper permissions to a Node.js folder in IIS, give the following object write access:
IIS AppPool\<app identity>
@pmanijak
pmanijak / design-doc.js
Last active August 29, 2015 14:04
Example CouchDB design document with map-reduce
// Most of the times an aggregation function is needed,
// it is a simple count or sum, which are supported by
// built-in functions of both CouchDB and MongoDB.
//
// This is a CouchDB design document:
var circlesDesignDoc = {
url: '_design/circles',
body: {
version: "1.0.1",
@pmanijak
pmanijak / .Deploy Circle Blvd with git push
Last active August 29, 2015 14:00
Circle Blvd: Deploy with git, precariously: http://circleblvd.org
1. Prerequisites (see below)
2. Set up the server
3. Set up the client
@pmanijak
pmanijak / Run Circle-Blvd on EC2
Last active August 29, 2015 14:00
Circle Blvd server setup on Ubuntu 14 on Amazon: http://circleblvd.org
These are instructions for setting up Circle Blvd on an Amazon EC2 instance running Ubuntu,
or really any Ubuntu server you are happy with.
It assumes the default user account is 'ubuntu' (created by the AMI).
Directions:
0. Create an EC2 instance using Amazon Web Services
--> AMI: Ubuntu Server 14 (free tier)
--> Security group: Add HTTP, HTTPS, and SSH rules
@pmanijak
pmanijak / Auto-deploy with git on Webfaction
Last active August 1, 2018 03:25
Setting up a simple auto-deploy with git on Linux
On server
-----------------
# make a git repo
$ mkdir /path/to/repo.git
$ cd /path/to/repo.git
$ git init --bare
# make a post-receive hook
# see the post-receive file in this Gist
# if you're using Node.js