Skip to content

Instantly share code, notes, and snippets.

View auggernaut's full-sized avatar

Augustin Bralley auggernaut

View GitHub Profile
@auggernaut
auggernaut / login.js
Created September 9, 2013 22:20
check if passwords match
if ($("#reg-password2").val() === $("#reg-password1").val()) {
} else {
$("#register-message").show().html("Passwords do not match.");
$("#register-message").addClass("text-error");
}
@auggernaut
auggernaut / login.js
Created August 16, 2013 20:21
Update Parse.User
user.set({stardust: res});
user.save(null, {
success: function(){
StarDust.save("user", user);
window.location.href = "#profile";
},
error: function(){
$("#register-message").show().html("Error updating parse.");
}
});
@auggernaut
auggernaut / couch.js
Created July 16, 2013 00:51
Creating a per-user Database in CouchDB with nano, using promises.
var q = require('q');
exports.findOrCreateDB = function (config, creds, cb) {
var nano = require('nano')("http://" + config.couch_admin + ":" + config.couch_password + "@" + config.couch_host + ':' + config.couch_port);
var users = nano.use('_users');
var user = {
_id: "org.couchdb.user:" + creds.username,
name: creds.username,
@auggernaut
auggernaut / couch.js
Last active August 23, 2021 16:47
Creating a per-user Database in CouchDB with nano.
exports.findOrCreateDB = function (config, creds, cb) {
var nano = require('nano')("http://" + config.couch_admin + ":" + config.couch_password + "@" + config.couch_host + ':' + config.couch_port);
var users = nano.use('_users');
var user = {
_id: "org.couchdb.user:" + creds.username,
name: creds.username,
roles: [],
type: "user",
@auggernaut
auggernaut / styles.css
Created May 14, 2013 22:37
Rounded image bubbles and blockquotes.
.home .mb-wrap {
padding: 20px;
position: relative;
}
.home .mb-wrap p{
margin: 0;
padding: 0;
}
@auggernaut
auggernaut / reply.js
Created May 14, 2013 02:16
Shortest javascript image uploaded to imgur.
//ADD IMAGE
//http://hacks.mozilla.org/2011/03/the-shortest-image-uploader-ever/
var files = $('input[id = upImage]')[0].files;
var file = files[0];
if (!file || !file.type.match(/image.*/)) return;
var fd = new FormData();
fd.append("image", file);
fd.append("type", "file");
fd.append("name", "test");
@auggernaut
auggernaut / snippets.js
Created May 14, 2013 01:36
Read an array of image files with FileReader
//ADD IMAGE
//http://www.html5rocks.com/en/tutorials/file/dndfiles/
var files = $('input[id = file]')[0].files; // FileList object
var fileName = $('#pretty-input').val();
// Loop through the FileList
for (var i = 0, f; f = files[i]; i++) {
// Only process image files.
if (!f.type.match('image.*')) {
continue;