Skip to content

Instantly share code, notes, and snippets.

View steveinatorx's full-sized avatar

steven brezina steveinatorx

View GitHub Profile
@steveinatorx
steveinatorx / app.css
Created March 23, 2015 23:50
a simple inline loading animation as an angular directive
#fadingBarsG{
position:relative;
width:100px;
height:12px;
display:inline-block;
}
.fadingBarsG{
position:absolute;
top:0;
<!DOCTYPE html>
<html>
<head>
<script src="https://rawgit.com/lodash/lodash/3.0.1/lodash.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@steveinatorx
steveinatorx / keystone--routes--api--themodel.js
Created June 21, 2016 20:14
keystonejs update http PUT model api call
var keystone = require('keystone');
var TheModel=keystone.list('TheModel');
var _=require('lodash');
exports.update=function(req, res) {
TheModel.model.findOneAndUpdate({"id":req.params.id},{$set:req.body},{new:true},function(err, doc) {
if (err) return res.apiError('error', err);
res.apiResponse({
@steveinatorx
steveinatorx / Gulpfile.js
Created July 29, 2016 22:27 — forked from webdesserts/Gulpfile.js
Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise.
var gulp = require('gulp'),
spawn = require('child_process').spawn,
node;
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
'use strict';
var apiDispatcher = require ('../apiDispatcher');
var request = require ('request');
var async = require ('async');
apiDispatcher.getURIs('foo.com')
.then(function(res){
var uris=JSON.parse(res);
async.each(uris, function(uri,tick){
@steveinatorx
steveinatorx / nodeGrep.sh
Created August 13, 2016 21:42
super simple recursive grep exclude node_modules
#!/bin/bash
find . \( -name node_modules -prune \) -o -name "*.*" -exec grep --color -Hn $1 {} 2>/dev/null \;
// find the latest query that matches criteria in mongodb
db.system.profile.find({ "op" : "command", "command.query.Criteria" : {"$exists": true} }, { "command" : 1}).limit(1).sort( { ts : -1 } ).pretty()
@steveinatorx
steveinatorx / asynchronous require in node
Created November 19, 2016 00:28
asynchronous require in node
/* i needed to load a bunch of static filter arrays into an api route in node - express -
so rather than making that DB call every time i ran the
api route here is a keen pattern to require async - use require with a callback.
This is a quick and easy way to do "poor man's server caching" with node in a server context
*/
require('./apiHelper').getOptFilter(function(err, filter){
console.log('i got the filter now load the rest of my route/module', filter);
});

Keybase proof

I hereby claim:

  • I am steveinatorx on github.
  • I am stevenbrezina (https://keybase.io/stevenbrezina) on keybase.
  • I have a public key ASCVVM9t3-nlt8tqeeoZs_9bUM9x0slAZI9DVAQbUMNhiAo

To claim this, I am signing this object: