Skip to content

Instantly share code, notes, and snippets.

View servel333's full-sized avatar

Nathaniel Perry servel333

View GitHub Profile
var run_cmd = function(cmd, args) {
var promise = require('bluebird');
return new promise(function (resolve, reject) {
var spawn = require('child_process').spawn;
var child = spawn(cmd, args);
var resp = "";
child.stdout.on('data', function (buffer) { resp += buffer.toString() });
//child.stdout.on('end', function(){ resolve(resp); });
child.on('close', function(exitCode){ resolve(resp); }); // < This might be more approperate
@servel333
servel333 / recurseKeys.js
Created September 29, 2015 15:30
Shows keys recursively from a root object.
var lodash = require('lodash');
var _seenObjects = [];
var recurseKeys = function(name, obj){
var duplicate;
if (( duplicate = lodash.find(_seenObjects, function(seen){
return seen.obj === obj;
}) )) {
@servel333
servel333 / Tags._collection.rawCollection.log
Last active September 29, 2015 15:36
MongoDB Collection Keys
meteor shell
> recurseKeys('Tags._collection.rawCollection()', Tags._collection.rawCollection());
Tags._collection.rawCollection() => {Object}
Tags._collection.rawCollection().db => (DUPLICATE of Tags._driver.mongo.db)
Tags._collection.rawCollection().collectionName => {String}
Tags._collection.rawCollection().internalHint => NULL
Tags._collection.rawCollection().opts => {Object}
Tags._collection.rawCollection().slaveOk => {Bool} false
Tags._collection.rawCollection().serializeFunctions => {Bool} false
<code><pre>
{% set root_val = varilable_to_debug %}
root_val: {{ root_val }}
{{ root_val|length }}
{% for key, value in root_val %}
root_val.{{ key }} => {{ value }}
{% for key2, value2 in value %}
root_val.{{ key }}.{{ key2 }} :: {{ value2 }}
{% for key3, value3 in value2 %}

API model query string

  • is_archived=*: Returns a list of both soft-deleted and non-soft-deleted records
  • is_archived=true: Returns a list of only soft-deleted records
  • is_archived=false: Returns a list of only non-soft-deleted records
  • absent is_archived: Returns a list of only non-soft-deleted records

Example

@servel333
servel333 / macbookpro-packages.sh
Last active October 6, 2017 18:51
Suggested packages for a MacBook Pro
# Suggested packages for a MacBook Pro
# Created Sep 2017 for a MacBook Pro Late 2013
lsb_release -a
# -> Description: Ubuntu 17.04
# -> Codename: zesty
# Read your model
sudo dmidecode -s system-product-name
# -> MacBookPro11,3
@servel333
servel333 / handlebars-operators.md
Created February 15, 2018 15:39
Handlebars {{#if (op ... )}} operators
@servel333
servel333 / runnable.js
Last active October 8, 2021 16:31
JavaScript one-liners and simple blocks, and some bash
#!/usr/bin/env node
/* eslint-disable no-alert */
/* eslint-disable no-console */
const allParams = process.argv.slice(2).join(' ');
const relativeDir = require('path').resolve(__dirname, '../some/path');
const thisScript = require('path').basename(__filename);
@servel333
servel333 / GUIDE.MD
Last active December 22, 2020 16:33
API Query String Parameter Style Guide

Motivation

There is no clear standard (or this is a "yet another"?) for formatting query string parameters for various applications in an API.

Problems

Specify model attributes to filter on

  • &attribute[ATTRIBUTE-NAME]=ATTRIBUTE-VALUE

Specify model attributes to filter on with operators

  • Operators: greater than, greater than or equal, less than, less than or equal, in, etc...
@servel333
servel333 / Steam-Deck-notes.md
Last active September 9, 2022 00:42
Steam Deck notes and information