Skip to content

Instantly share code, notes, and snippets.

View jcrugzz's full-sized avatar

Jarrett Cruger jcrugzz

View GitHub Profile
#!/usr/bin/env node
var _ = require("underscore"),
async = require("async"),
exec = require("child_process").exec,
ProgressBar = require("progress"),
treeify = require("treeify");
var keep = [];
@bmeck
bmeck / runner.js
Created January 30, 2015 18:01
Example of making a complex runner capable of limited concurrency, disjoint continuation, and mixed concurrency/parallelism
// an example of using async / await style scheduling using callbacks
// we can do things without promises and get some nicer (imho) results
// promises still work here, but are not shown for advanced cases
function* task(step) {
//
// simple callback style continuation
//
yield _ => setTimeout(_,0);
@aleksi-niiranen
aleksi-niiranen / SomeActivity.java
Created July 9, 2012 19:11
Loading view popup in Android
public class SomeActivity extends Activity {
// make it a field so we can dismiss it when the activity pauses.
// otherwise the window will leak and cause and exception when the activity no longer exists
private PopupWindow mPopup;
public void showPopup() {
View popupView = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.indeterminate_progress, null);
Display display = getWindowManager().getDefaultDisplay();
// getWidth() and getHeight() are deprecated and we should use getSize() but it's available on API level 13 and up
mPopup = new PopupWindow(popupView, display.getWidth(), display.getHeight());

Overview

PouchDB is a database written in JavaScript for web browsers that has in built sync capabilities.

For a long time 'web' was synonymous with 'online'. That is no longer the case, Mobile web usage is set to overtake desktop web usage shortly and a growing number of examples are showing that web technology is capable of handling the type of applications that were traditionally built using desktop native technology.

The new wave of offline web applications are going to need somewhere to store their data and they are going to need to learn how to move that data around as their user moves from device to device. How about we build a database with that functionality built in?

Objective

@jhs
jhs / example.js
Created December 10, 2012 03:16
My Node.js modules these days
// Short module explanation // Something to gather my thoughts
// // I think this looks cool.
//
module.exports = the_exported_function // Modules are a function. Always.
//
module.exports.extra = extra // Additional API entry points if
module.exports.other = other // desired.
//
var util = require('util') // Other packages from npm or core
var assert = require('assert') // No comma-first due to lots of

Hi, all.

Encouraged by my successful experiment with a Node.js view server, I am now working on a branch, nodejs_couchdb, with the following properties:

  • Remove couchjs from the project
  • Remove dependency on SpiderMonkey, libjs, 1.8.whatever...all that is gone
  • Remove dependency on libcurl
  • (Thus, simplified autoconf version dependency Hell)

Phase 1: Dependency on a "couchjs" executable which you install via npm install couchjs

@blakmatrix
blakmatrix / gist:4956455
Last active December 13, 2015 18:38
get last 100 lines from logs nodejitsu
curl -X POST -H "Content-Type: application/json" \
https://api.nodejitsu.com/logs/<username>/<appname> \
-d '{"from":"NOW-1DAY","until":"NOW","rows":100}' \
-u <username>:<password/token> | node -e \
"process.stdin.resume();
process.stdin.setEncoding('utf8');
var str = '';
process.stdin.on('data', function (chunk) {str += chunk.toString();});
process.stdin.on('end', function () {
JSON.parse(str).data.forEach(function(i){process.stdout.write(i.json.message);});});"
@indexzero
indexzero / reduce-dir.js
Created March 23, 2013 22:13
Recursively build an object of all files and directories in a directory tree.
var fs = require('fs'),
path = require('path'),
async = require('async');
function reduceDir(dir, mem, callback) {
if (!callback && typeof mem === 'function') {
callback = mem;
mem = null;
}
@indexzero
indexzero / swap.sh
Created May 18, 2013 01:24
Increased swap space
dd if=/dev/zero of=/swap bs=1024 count=4194304
mkswap /swap
echo "/swap swap swap sw 0 0" >> /etc/fstab
@wolfeidau
wolfeidau / httpstest3.js
Last active December 24, 2015 23:49
NodeJS stdlib Post
'use strict';
var url = require('url');
var creds = require('./creds.js');
var https = require('https');
var scheme = 'https';
var hostname = 'api.tempo-db.com';
var baseUrl = scheme + '://' + hostname;