Skip to content

Instantly share code, notes, and snippets.

View showing-merged-data.handlebars
<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>
View controller.js
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);
});
View loan-model.js
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: {
View corruption-index.js
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 Apr 19, 2018
Testing data load into MongoDB of Kiva API data
View testing-data-load.js
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
View gist:4487004
========================================================
========================================================
-- 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 Dec 10, 2015
Rackspace Identity v2.0 XML Authentication with API key
View gist:4353241
#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
View runMigrate.pl
#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)
View keystone_ldap.sh
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 Feb 16, 2012
configuration_file_gist_test
View gist_test.conf
ENV=TEST
USER=ME
CONFIGFILE=/a/b/c/d.ef
#comment blah
You can’t perform that action at this time.