Skip to content

Instantly share code, notes, and snippets.

<div class="row">
{{#each loans}}
<div class="card" style="width: 18rem; height: 36rem">
<a class="card-link" href="https://www.kiva.org/lend/{{id}}">
<img class="card-img-top" width="288" height="288" src="https://www.kiva.org/img/288x288/{{image.id}}.jpg}">
</a>
<div class="card-body">
<ul class="list-group list-group-flush">
<li class="list-group-item">{{name}} from {{location.country}} is requesting {{loan_amount}} {{use}}</li>
</ul>
LoanModel.find({},{},{limit: 4, sort:{timestamp:-1}}).exec(function(error, loans) {
if(error){throw error;}
for (var i = 0; i<loans.length; i++) {
viewModel.loans[i]=loans[i].toObject();
}
res.render('index',viewModel);
});
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
path = require('path'),
Cindex =require('./cindex');
mongoose.set('debug', true); // shows calls against mongoDB. Should be turned off in prod.
var loanSchema = new Schema({
loans: {
id: {
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
path = require('path');
var corruptSchema = new Schema({
corrupts: {
Country : {
type: 'String'
},
ISO3: {
@joesavak
joesavak / testing-data-load.js
Last active April 19, 2018 15:53
Testing data load into MongoDB of Kiva API data
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
//connect to local datastore
mongoose.connect('mongodb://localhost/kivaDB');
mongoose.connection.on('open', function () {
console.log('Mongoose connected');
});
//set schema, based on https://transform.now.sh/json-to-mongoose
@joesavak
joesavak / gist:4487004
Created January 8, 2013 19:18
mfa contract
========================================================
========================================================
-- V2.0 OS-MF Multi Factor Extension
========================================================
XML
<?xml version="1.0" encoding="UTF-8"?>
<auth xmlns:os-mf="http://docs.openstack.org/identity/api/ext/OS-MF/v1.0">
<token id="abcdefghijklmnop"/>
<OS-MF:multifactor factor="PASSCODE" code="124398" >
</auth>
@joesavak
joesavak / gist:4353241
Last active December 10, 2015 00:39
Rackspace Identity v2.0 XML Authentication with API key
#authentication with username & API key:
curl $identity/v2.0/tokens -d '<?xml version="1.0" encoding="UTF-8"?><auth><apiKeyCredentials xmlns="http://docs.rackspace.com/identity/api/ext/RAX-KSKEY/v1.0" username="USERNAME" apiKey="APIKEY" /></auth>' -H "Content-type: application/xml" -H "Accept: application/xml"
#authentication with username, API key, and tenantId:
curl $identity/v2.0/tokens -d '<?xml version="1.0" encoding="UTF-8"?><auth><apiKeyCredentials xmlns="http://docs.rackspace.com/identity/api/ext/RAX-KSKEY/v1.0" username="USERNAME" apiKey="APIKEY" tenantId="TENANTID" /></auth>' -H "Content-type: application/xml" -H "Accept: application/xml"
#example response:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<access
@joesavak
joesavak / runMigrate.pl
Created September 27, 2012 17:09
runMigrate
#one of many threads running to not impede migration velocity
Foreach user(@users)
migrate($user)
setDisableFlagInGA($user) #still route to CAuth
$change=true
while change
data A= getUserData($user)
sleep(61) #sleep 61 minutes
data B = getUserData($user)
@joesavak
joesavak / keystone_ldap.sh
Created September 10, 2012 21:12
Keystone and ldap
git clone https://github.com/openstack/keystone.git
sudo apt-get install python-dev libxml2-dev libxslt1-dev libsasl2-dev libsqlite3-dev libssl-dev libldap2-dev
pip install -r tools/pip-requires
pip install -r tools/test-requires
python setup.py develop
#links
#http://adam.younglogic.com/2012/02/openstack-keystone-ldap-redux/
#http://www.youtube.com/watch?v=Istj0_-BwmQ
@joesavak
joesavak / gist_test.conf
Created February 16, 2012 19:47
configuration_file_gist_test
ENV=TEST
USER=ME
CONFIGFILE=/a/b/c/d.ef
#comment blah