Skip to content

Instantly share code, notes, and snippets.

View longlostnick's full-sized avatar

Nick Larson longlostnick

View GitHub Profile
blockquote {
background: #f7f7f7;
font-family: Georgia;
padding: 14px 14px 12px 12px !important;
border: 1px solid #e7e7e7;
margin: 1em 3em;
text-align: right;
font-size: 10pt;
-webkit-border-radius: 5px;
@longlostnick
longlostnick / each_async.js
Created March 9, 2012 01:18
Asynchronous Each
function eachAsync(arr, _block, _callback) {
var i = 0, processing = false;
var thread = setInterval(function() {
if (!processing) {
processing = true;
_block(arr[i]);
i++;
if (i >= arr.length) {
clearInterval(thread);
if (_callback) _callback();
@longlostnick
longlostnick / find_replace_all.rb
Created December 18, 2012 21:15
Find and replace using split and join.
string = "this is cool"
"*#{string}*".split("cool").join("dumb")[1..-2]
# => "this is dumb"
def print_repeating(array)
0.upto(array.size - 1) do |i|
flag = array[array[i].abs]
flag = 1 if flag.nil?
if flag >= 0
array[array[i].abs] = -flag
else
@longlostnick
longlostnick / gist:5461340
Created April 25, 2013 17:02
Try to detect when someone's mouse is moving upward off the page
(function() {
var current_scroll = 0;
var last_mouse_y = null;
$(document)
.scroll(function() {
current_scroll = $(this).scrollTop();
})
.mousemove(function(e) {
@longlostnick
longlostnick / breadcrumbs.rb
Last active December 17, 2015 14:29
Breadcrumbs
module Breadcrumbs
def self.included(base)
base.extend ClassMethods
end
def add_breadcrumb(name, path)
@breadcrumbs ||= []
@breadcrumbs << Breadcrumb.new(name, path)
end
this.editor = new wysihtml5.Editor("textarea");
this.editor.observe("load", function () {
var $iframe = $(this.composer.iframe);
var $body = $(this.composer.element);
$body
.css({
'min-height': 0,
'line-height': '20px',
'overflow': 'hidden',
# Splunk Storm
$ wget [ Download Splunk url ]
$ gunzip -c splunkforwarder-5.0-140868-Linux-x86_64.tgz | tar -xvpf -
$ ./splunkforwarder/bin/splunk start
$ ./splunkforwarder/bin/splunk install app stormforwarder_3de50bc823a711e2b4a81231390e9c34.spl -auth admin:changeme
$ ./splunkforwarder/bin/splunk login -auth admin:changeme
$ ./splunkforwarder/bin/splunk edit user admin -password whatever_you_want
$ ./splunkforwarder/bin/splunk add forward-server forwarder.splunkstorm.com:9997
$ ./splunkforwarder/bin/splunk add monitor /var/www/monologapp/log/fideloper.log # Starts sending data
$ ./splunkforwarder/bin/splunk add monitor /var/log/apache2/error.log
@longlostnick
longlostnick / 0_reuse_code.js
Created March 21, 2014 17:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
worker_processes 4
timeout 20
preload_app true
listen ENV['PORT'].to_i, backlog: 10
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid