Skip to content

Instantly share code, notes, and snippets.

@unkleara
unkleara / duplicate-element-checker-as-module
Last active August 29, 2015 14:20
Had issue's properly solving this so I spent some time going over it.
//two seperate arrays with some duplicate numbers
//use object to hold values from larger array as keys
//compare second/smaller array against object.keys from first/larger array
//add duplicates to new array and return new array
var ArrayDuplicateFinder = (function() {
//Private variable
var arrayHash = {};
@unkleara
unkleara / Sidekiq Reset
Last active January 6, 2021 18:51
Sidekiq reset stats
To reset processed jobs:
Sidekiq.redis {|c| c.del('stat:processed') }
To reset failed jobs:
Sidekiq.redis {|c| c.del('stat:failed') }
To reset statistics:
Sidekiq::Stats.new.reset
@unkleara
unkleara / ng-bs-acme.js
Created November 27, 2013 02:24
dl common buttons
app.directive('editButton', [ function(){
return {
restrict: 'EA',
replace : true,
scope : {
text : '@',
action : '&'
},
template: '<button class="btn btn-xs btn-info" ng-click="action()"><i class="fa fa-edit"></i> {{text}}</button>'
@unkleara
unkleara / formData.js
Created November 24, 2013 11:53
geobytes service angularjs and lodash
app.factory('geoData', ['$http', '$q', 'limitToFilter', function ($http, $q, limitToFilter) {
return {
get: function(inputValue) {
var url = "http://gd.geobytes.com/AutoCompleteCity?callback=JSON_CALLBACK &filter=US&q=";
//since $http.get returns a promise,
//and promise.then() also returns a promise
//that resolves to whatever value is returned in it's
//callback argument, we can return that.
return $http.jsonp(url + inputValue)
.then(function (result) {
@unkleara
unkleara / gist:7110767
Last active December 26, 2015 06:49
mongdb/mongoid geospatial queries
location = params[:query][:location]
radius = params[:query][:radius]
@items = Item.where({:'origin.coordinates' => { "$within" => { "$centerSphere" => [ location, (radius.fdiv(3959) )]}}})
T controller
@t = Location.where({:'origin.coordinates' => {"$within" => {"$centerSphere" => [origin, (oradius.fdiv(3959))]}}, '$and' => [{:'destination.states'.in => [state]}, "$or" => {:'destination.coordinates' => {"$within" => {"$centerSphere" => [dest, (dradius.fdiv(3959))]}}}]})
@unkleara
unkleara / angular-input-types.txt
Last active December 20, 2015 10:49
Making collection of angular.js input types to reference.
<select ng-model='param' required ng-options='option.value as option.name for option in scope'>
<option></option>
</select>
<input ng-model="param" placeholder="">
<button ng-click="yourFunction(params)"></button>
Bootstrap dropdown toggle prevent default event on checkbox input