Skip to content

Instantly share code, notes, and snippets.

View auggernaut's full-sized avatar

Augustin Bralley auggernaut

View GitHub Profile
@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;
@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 / 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 / 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 / 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 / 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 / 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 / LoginView.html
Created September 10, 2013 22:16
Login, Register, or FBConnect view
<div id="loginRegister">
<div id="login">
<h1>Login</h1>
<input type="text" value="" name="email" class="input-block-level" id="login-email"
placeholder="email" required>
<input type="password" value="" name="password" class="input-block-level" id="signin-password"
placeholder="password" required>
@auggernaut
auggernaut / login.js
Created September 10, 2013 22:35
GratziCosmos old login methods
var creds = { "user": $("#login-email").val(), "pass": $("#signin-password").val() };
var star;
var appname = Gratzi.Config.appName;
Gratzi.login(creds, function (err, res) {
if (res) {
console.log(res);
star = res.details.star;
Cosmos.login(creds, star, appname, function (err, res) {
@auggernaut
auggernaut / login.js
Created September 10, 2013 22:36
GratziCosmos old register methods
var creds = { "user": $("#username").val(), "email": $("#email").val(), "pass": $("#reg-password").val() };
var user;
var appname = Gratzi.Config.appName;
Gratzi.register(creds, function (err, res) {
if (res) {
console.log(res);
user = res.details;