Skip to content

Instantly share code, notes, and snippets.

View pauliusuza's full-sized avatar
🔥
On fire

Paulius Uza pauliusuza

🔥
On fire
View GitHub Profile
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.

Pub/sub with MongoDB and Node.js

Setup:

$ mongo
> use pubsub
> db.createCollection('messages', { capped: true, size: 100000 })
> db.messages.insert({})
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert')
console.log('\n===========');
console.log(' mongoose version: %s', mongoose.version);
console.log('========\n\n');
<!DOCTYPE html>
<html lang='en'>
<head>
<script>
var Keen=Keen||{configure:function(e){this._cf=e},addEvent:function(e,t,n,i){this._eq=this._eq||[],this._eq.push([e,t,n,i])},setGlobalProperties:function(e){this._gp=e},onChartsReady:function(e){this._ocrq=this._ocrq||[],this._ocrq.push(e)}};(function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src=("https:"==document.location.protocol?"https://":"http://")+"dc8na2hxrj29i.cloudfront.net/code/keen-2.1.0-min.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})();
// Configure the Keen Client
Keen.configure({
projectId: "<your project ID>",

Cheat Sheet for the FoundationDB 'Hot Cloud Swap' Screencast

Initial Cluster Setup on Digital Ocean

Grab the client and server packages from the FoundationDB website

ansible -i inventory digital_ocean -a "wget https://foundationdb.com/downloads/f-nbxofdxnoxocd/I_accept_the_FoundationDB_Community_License_Agreement/key-value-store/2.0.9/foundationdb-clients_2.0.9-1_amd64.deb https://foundationdb.com/downloads/f-nbxofdxnoxocd/I_accept_the_FoundationDB_Community_License_Agreement/key-value-store/2.0.9/foundationdb-server_2.0.9-1_amd64.deb"

Install the client and server packages

with
dau as (
-- This part of the query can be pretty much anything.
-- The only requirement is that it have three columns:
-- dt, user_id, inc_amt
-- Where dt is a date and user_id is some unique identifier for a user.
-- Each dt-user_id pair should be unique in this table.
-- inc_amt represents the amount of value that this user created on dt.
-- The most common case is
-- inc_amt = incremental revenue from the user on dt
@pauliusuza
pauliusuza / package_info2dot.js
Created May 6, 2016 12:00 — forked from pmuellr/package_info2dot.js
Generate a diagram of package deps for running N|Solid instances, in graphviz dot notation, using the N|Solid agent `package_info` command. For more info on N|Solid, head over to https://nodesource.com/products/nsolid
#!/usr/bin/env node
// Generate a graphviz (graphviz.org) .dot file for the package relationships
// of the currently running N|Solid instances, using the N|Solid 1.3
// package_info command.
'use strict'
var fs = require('fs')
var path = require('path')
@pauliusuza
pauliusuza / ArtistList.js
Created March 13, 2017 13:07 — forked from n1ru4l/ArtistList.js
mobx + apollo-client + react
import React from 'react'
import { observer } from 'mobx-react'
function ArtistList({ uiState: { artistData } }) {
const { data } = artistData;
if ( !data || !data.artists || !data.artists.length ) {
return <div>No artists bruh.</div>
}
const { artists } = data
return (
const {
Client,
Signature,
cryptoUtils,
} = require('dsteem');
const client = new Client('https://api.steemit.com');
const args = process.argv.slice(2);