Skip to content

Instantly share code, notes, and snippets.

View jimschubert's full-sized avatar
🎯
Always here to help.

Jim Schubert jimschubert

🎯
Always here to help.
  • Richmond, VA
View GitHub Profile
@typesafe
typesafe / tabindex directive
Created April 11, 2014 16:33
angularjs directive to make tabindex attributes work with routing
MyModule.directive('tabindex', function () {
return {
restrict: 'A',
link: function (scope, elem, attr, ctrl) {
if (attr.tabindex == 1) {
elem.focus();
}
}
};
});
@jimthedev
jimthedev / init-angular2-ts-jspm
Created July 7, 2015 15:17
Angular2, TypeScript, JSPM starter script
# DESCRIPTION
# Performs the commands needed to download and set up a new angular2 project using typescript and jspm
#
# Assumes you have these:
# - git
# - node / io.js
# - npm
# - npm install -g jspm@beta **NOTE**: you must have the beta release of jspm installed
#
# USAGE
@cbumgard
cbumgard / index.js
Created November 15, 2012 02:20
Dynamic config module for node.js apps to simplify managing configurations for different environments. Reads in a config file matching the current NODE_ENV.
// This module loads a config file in the current working directory matching the NODE_ENV variable.
// I.e. either './development.js' or './production.js' based on the process.env.NODE_ENV variable.
// If not set, it defaults to './development.js'.
// Can load custom environment files as well, as long as the NODE_ENV variable matches
// a file in the current directory. E.g. './staging.js'
// Usage: calling code can just require this module, e.g. "var config = require('./config')"
// assuming this file is named "index.js" and lives in a subdirectory named "config" of the app root.
var config
, config_file = './' + (process.env.NODE_ENV ? process.env.NODE_ENV : 'development') + '.js';
@rehevkor5
rehevkor5 / ncdc.sh
Last active April 17, 2017 22:00 — forked from tomasdelvechio/ncdc.sh
Download a weather dataset from the National Climatic Data Center (NCDC, http://www .ncdc.noaa.gov/). Prepare it for examples of "Hadoop: The Definitive Guide" book by Tom White. http://www.amazon.com/Hadoop-Definitive-Guide-Tom-White/dp/1449311520 Usage: ./ncdc.sh 1901 1930 # download wheather datasets for period from 1901 to 1930. This version…
#!/usr/bin/env bash
# global parameters
g_tmp_folder="ncdc_tmp";
g_output_folder="ncdc_data";
g_remote_host="ftp.ncdc.noaa.gov";
g_remote_path="pub/data/noaa";
@vichango
vichango / Begin document
Last active September 9, 2017 20:49
Scrivener LaTeX Compile options
\usepackage{authblk}
\title{\mytitle}
\author[*]{\myauthor}
\affil[*]{\affiliation}
% To remove the date
\date{}
\begin{document}
@rodolfo42
rodolfo42 / Db.scala
Last active January 17, 2018 15:23
How to use transactions with finagle-mysql
package transactions
import com.twitter.finagle.exp.mysql.{Client, OK, Result}
class Db(mysqlClient: Client) {
val insertOrder = "INSERT INTO orders (ref) VALUES(?)"
val insertOrderItem = "INSERT INTO order_items (order_id, item_id) VALUES(?, ?)"
def persistOrderWithItems[T](order: Order)(whenDone: (OK, Seq[Result]) => T): Future[T] = {
@jimschubert
jimschubert / swagger.sh
Last active March 26, 2018 01:35
Quick script for running swagger codegen cli directly
#!/bin/bash
ver=2.3.1
jar=swagger-codegen-cli-$ver.jar
md5=c838c266b80401ecd43521890b4abea8
repo="http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/$ver/$jar"
if [ ! -f $jar ]; then
echo "[info] downloading $PWD/$jar from $repo" 1>&2
if ! curl --location --silent --fail --remote-name $repo -o $jar; then
@piotrga
piotrga / Json.scala
Last active April 4, 2018 07:42
The simplest dynamically typed json parsing with Dynamic in Scala 2.10
import util.parsing.json.JSON
import io.Source
import scala.language.dynamics
object Example extends App{
val json = """{
"name" : "Adam Slodowy",
"active": "true",
"roles" : [ "teacher", "admin" ],
@jaredhanson
jaredhanson / gist:3989193
Created October 31, 2012 19:13
Node Knockout 2012 - Getting Started with Passport
var express = require('express'),
passport = require('passport'),
TwitterStrategy = require('passport-twitter').Strategy,
ensureLoggedIn = require('connect-ensure-login').ensureLoggedIn,
app = express();
app.use(express.static(__dirname + '/public'));
app.use(express.cookieParser());
app.use(express.session({ secret: 'keyboard cat' }));
app.use(passport.initialize());
@jimschubert
jimschubert / openapi-generator-cli.sh
Last active July 7, 2018 04:19
Script for running openapi-generator-cli
#!/usr/bin/env bash
####
# Save as openapi-generator-cli on your PATH. chmod u+x. Enjoy.
#
# This script will query github on every invocation to pull the latest released version.
# If you want repeatable executions, you can explicitly set a version via
# OPENAPI_GENERATOR_VERSION
# e.g.
# export OPENAPI_GENERATOR_VERSION=3.1.0
# openapi-generator-cli.sh