Skip to content

Instantly share code, notes, and snippets.

View ferronrsmith's full-sized avatar
⛱️
Chilling on the beach

Ferron H ferronrsmith

⛱️
Chilling on the beach
View GitHub Profile
@ferronrsmith
ferronrsmith / elastic_cong.md
Last active August 29, 2015 14:16
ElasticSearch Configuration

ElasticSearch Configuration

Resource Limits

ElasticSearch has the best performance when it has a lot of resources (open files and RAM) available.

#/etc/security/limits.conf

elasticsearch - nofile 65535
@ferronrsmith
ferronrsmith / parallel.sh
Created March 14, 2015 02:20
parallel.sh
#!/bin/bash
NUM=0
QUEUE=""
MAX_NPROC=2 # default
REPLACE_CMD=0 # no replacement by default
USAGE="A simple wrapper for running processes in parallel.
Usage: `basename $0` [-h] [-r] [-j nb_jobs] command arg_list
-h Shows this help
-r Replace asterix * in the command string with argument
-j nb_jobs Set number of simultanious jobs [2]
#!/bin/sh
# NOTE: this script is largely inspired by Meteor install script,
# which can be found here: https://install.meteor.com
## NOTE sh NOT bash. This script should be POSIX sh only, since we don't
## know what shell the user has. Debian uses 'dash' for 'sh', for
## example.
# Is RESTX already installed (in /usr/local/bin (engine) or /usr/bin
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = true
@ferronrsmith
ferronrsmith / EmptyCollectionContractResolver.cs
Last active September 10, 2015 20:43 — forked from ejsmith/EmptyCollectionContractResolver.cs
EmptyCollectionContractResolver
class EmptyCollectionContractResolver : DefaultContractResolver {
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) {
JsonProperty property = base.CreateProperty(member, memberSerialization);
Predicate<object> shouldSerialize = property.ShouldSerialize;
property.ShouldSerialize = obj => (shouldSerialize == null || shouldSerialize(obj)) && !IsEmptyCollection(property, obj);
return property;
}
private bool IsEmptyCollection(JsonProperty property, object target) {
@ferronrsmith
ferronrsmith / readme.md
Created October 25, 2015 14:29 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@ferronrsmith
ferronrsmith / placeholder.js
Last active December 17, 2015 14:19
The following functionality is a custom-based poly-fill placeholder for AngularJS. For browsers lower than IE 10 the in-built placeholder functionality is used, otherwise the poly-fill is used
/***
* The following functionality is a custom-based poly-fill placeholder for AngularJS
* @example <input id="weight" name="weight" type="number" defaulttext="enter your weight"
* min="50" max="500" required />
* For browsers lower than IE 10 the in-built placeholder functionality is used, otherwise
* the poly-fill is used
*/
app.directive('defaulttext', function($timeout){
if (!$.browser.msie || $.browser.version >= 10) {
return {
@ferronrsmith
ferronrsmith / ngEvent.js
Last active December 17, 2015 14:19
General-purpose Event binding. Bind any event not natively supported by Angular Pass an object with keynames for events to ng-event Allows $event object and $params object to be passed
/**
* General-purpose Event binding. Bind any event not natively supported by
* Angular Pass an object with keynames for events to ng-event Allows $event
* object and $params object to be passed
*
* @example <input ng-event="{ focus : 'counter++', blur : 'someCallback()' }">
* @example <input ng-event="{ myCustomEvent : 'myEventHandler($event,
* $params)'}">
*
* @param ng-event
@ferronrsmith
ferronrsmith / ngValidate.js
Last active December 17, 2015 14:19
General-purpose validator for ngModel. angular.js comes with several built-in validation mechanism for input fields (ngRequired, ngPattern etc.) but using an arbitrary validation function requires creation of a custom formatters and / or parsers. The ng-validate directive makes it easy to use any function(s) defined in scope as a validator funct…
/**
* General-purpose validator for ngModel. angular.js comes with several built-in
* validation mechanism for input fields (ngRequired, ngPattern etc.) but using
* an arbitrary validation function requires creation of a custom formatters and /
* or parsers. The ng-validate directive makes it easy to use any function(s)
* defined in scope as a validator function(s). A validator function will
* trigger validation on both model and input changes.
*
* @example <input ng-validate=" 'myValidatorFunction($value)' ">
* @example <input ng-validate="{ foo : '$value > anotherModel', bar :
@ferronrsmith
ferronrsmith / numeric.js
Created May 22, 2013 20:25
disallow numeric entry in a input field
app.directive('ng-numeric', function($log) {
return {
require: 'ngModel',
link: function (scope, element, attr, ngModelCtrl) {
function fromUser(text) {
var transformedInput = text.replace(/[^0-9]/g, '');
$log.info(transformedInput);
if(transformedInput !== text) {
ngModelCtrl.$setViewValue(transformedInput);
ngModelCtrl.$render();