Skip to content

Instantly share code, notes, and snippets.

👆
That guy... 🤦‍♂️

Ryan Schumacher jrschumacher

View GitHub Profile
@jrschumacher
jrschumacher / terser.js
Last active Jan 28, 2019
A terser script to minify all javascript files in a directory
View terser.js
const fs = require('fs')
const {sync: globSync} = require('glob')
const filesize = require('filesize')
const Terser = require('terser')
const options = require(process.env.TERSER_CONFIG || './terserrc.json')
const getSize = (file) => {
const {size} = fs.statSync(file)
return filesize(size)
}
@jrschumacher
jrschumacher / slack-minimize-sidebar.css
Last active Jun 15, 2018
Slack minimized sidebar (stylish
View slack-minimize-sidebar.css
@media (max-width: 950px) {
.client_channels_list_container {
max-width: 100px;
transition: 0.5s;
}
.client_channels_list_container:hover {
max-width: 220px;
}
.client_channels_list_container .p-channel_sidebar {
max-width: 100px;
View nativefier-pivotal-tracker.sh
nativefier \
--name "Pivotal Tracker" \
--platform "darwin" \
--overwrite \
--icon ~/.nativefier/pivotal_tracker/icon.png \
"https://pivotaltracker.com" \
~/.nativefier/pivotal_tracker
@jrschumacher
jrschumacher / build-and-deploy.sh
Last active Apr 23, 2019
Ionic Automated Build and Deploy to HockeyApp
View build-and-deploy.sh
#!/bin/bash
PROJECT_NAME=MyApp
SCHEME_NAME=MyApp
STARTTIME=$(date +%s);
set -e
set -x
### Install dependencies
echo "--- Install dependencies [Time Elapsed $(($(date +%s) - $STARTTIME))s]"
@jrschumacher
jrschumacher / stream.js
Last active Aug 29, 2015
Loopback get current context: remote vs observe
View stream.js
//...
Stream.observe('before save', function test(ctx, next) {
console.log('>>>>> Stream.observe::before-save >>>>>\n',
loopback.getCurrentContext(),
'\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
next();
});
View gist:58e5189942f28053a9e1
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
32b9ac00b8fa dokku/coach:latest "/bin/bash -c '/star About an hour ago Up About an hour determined_bardeen
ed13cc0c60b6 dokku/helloworld:latest "/bin/bash -c '/star About an hour ago Up About an hour 0.0.0.0:49154->5000/tcp dreamy_hopper
@jrschumacher
jrschumacher / travis-ci-test-mongo-connectivity.yml
Created Mar 14, 2014
Travis-CI test for MongoDB connectivity before script
View travis-ci-test-mongo-connectivity.yml
# This script will test for MongoDB connectivity.
# If MongoDB is available then it continues else it tries X times then fails.
#
# Use: Add this to your `before_script` option
before_script:
- |
echo "Testing MongoDB connection...";tries=4;
i=0;
while [ $i -lt $tries ]; do fail=$(mongo --eval db 2>&1 >/dev/null | grep "connect failed");
@jrschumacher
jrschumacher / mongodb-shell-underscorejs.md
Last active Aug 29, 2015 — forked from vidoss/gist:2178987
MongoDB provides a Javascript shell. But Javascript is no fun without Underscore.js (http://underscorejs.org/). Here is how to add Underscore.js
View mongodb-shell-underscorejs.md

MongoDB provides a Javascript shell. But Javascript is no fun without Underscore.js

Turned out its straight forward to use Underscore.js while scripting mongodb.

Here are the steps:

  1. Download or clone Underscore.js and run...
% mongo server:27017/dbname underscore.js my_commands.js
View headjs.min.js.cached
(function(n,t){"use strict";function r(n){a[a.length]=n}function k(n){var t=new RegExp(" \\b"+n+"\\b");c.className=c.className.replace(t,"")}function p(n,t){for(var i=0,r=n.length;i<r;i++)t.call(n,n[i],i)}function tt(){var t,e,f,o;c.className=c.className.replace(/ (w-|eq-|gt-|gte-|lt-|lte-|portrait|no-portrait|landscape|no-landscape)\d+/g,""),t=n.innerWidth||c.clientWidth,e=n.outerWidth||n.screen.width,u.screen.innerWidth=t,u.screen.outerWidth=e,r("w-"+t),p(i.screens,function(n){t>n?(i.screensCss.gt&&r("gt-"+n),i.screensCss.gte&&r("gte-"+n)):t<n?(i.screensCss.lt&&r("lt-"+n),i.screensCss.lte&&r("lte-"+n)):t===n&&(i.screensCss.lte&&r("lte-"+n),i.screensCss.eq&&r("e-q"+n),i.screensCss.gte&&r("gte-"+n))}),f=n.innerHeight||c.clientHeight,o=n.outerHeight||n.screen.height,u.screen.innerHeight=f,u.screen.outerHeight=o,u.feature("portrait",f>t),u.feature("landscape",f<t)}function it(){n.clearTimeout(b),b=n.setTimeout(tt,50)}var y=n.document,rt=n.navigator,ut=n.location,c=y.documentElement,a=[],i={screens:[240,320,480,
@jrschumacher
jrschumacher / MongoQueryStr.php
Created Sep 1, 2013
Convert a PHP Mongo query with Mongo* classes to MongoDB js query. Currently supports MongoId => ObjectId, MongoDate => ISODate, and MongoRegex => RegExp. [VERY ROUGH] -- Wrote this because I was tired of getting stuck and having to port the query by hand.
View MongoQueryStr.php
<?php
class MongoQueryStr {
protected static $indent = 0;
public static function convert($query) {
if(!is_array($query)) {
return false;
}
You can’t perform that action at this time.