Skip to content

Instantly share code, notes, and snippets.

View nelix's full-sized avatar
🎯
Focusing

Nathan Hutchision nelix

🎯
Focusing
View GitHub Profile
@nelix
nelix / application_helper.rb
Created March 13, 2014 05:23
Little faye server with hmac authentication
def hmac_token(channel)
ident = {
user: current_user.id,
timestamp: Time.now.to_i,
channel: channel
}
puts "#{ident[:user]}:#{ident[:timestamp]}:#{ident[:channel]}"
digest = OpenSSL::HMAC.new(ENV['FAYE_SECRET_KEY'] || 'whocares?', 'SHA512')
digest << "#{ident[:user]}:#{ident[:timestamp]}:#{ident[:channel]}"
ident[:token] = digest.hexdigest
var itmes = this.props.ifSomething && arayOfThings.map(
function(thing) {
return <li>{thing}</li>
}
);
return (
<ul>{items}</ul>
);
@nelix
nelix / README
Last active December 26, 2015 22:39
Cloud66 postgresql with wal backups on S3
You need to do base backups often...
sudo -u postgres envdir /etc/wal-e.d/env /usr/local/bin/wal-e backup-push /usr/local/pgsql/data
You can check how many objects are not archived:
./var/backup_status.sh
@nelix
nelix / progress.js
Created September 12, 2013 03:53
some stuff.
$(document).ready( function() {
var form = $('#fileUpload'),
progress = $('#progress'),
data = new FormData();
form.submit(function(event) {
event.preventDefault();
var file = $('#file')[0];
progress.text('Starting to upload file:' + file.files[0].name);
@nelix
nelix / spec_helper.rb
Created July 25, 2013 02:20
Fix the case where random gems think fucking with at_exit is an OK thing todo.
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION >= "1.9"
module Kernel
alias :__at_exit :at_exit
def at_exit(&block)
__at_exit do
exit_status = $!.status if $!.is_a?(SystemExit)
block.call
exit exit_status if exit_status
end
end
function each(items,fn){[].forEach.call(items,fn)}
each(document.styleSheets, function(sheet){
if (sheet.cssRules) each(sheet.cssRules, function(r){
try{
// look for the first matching element
if(!document.querySelectorAll(r.selectorText)[0])
console.log("Unused Selector: ", r.selectorText);
} catch (e){
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
document.addEventListener("DOMContentLoaded", function(){
// an iframe and enough content to scroll is required
var iframe = document.getElementById('frame');
// if we touch this and there is a hash in the iframes parent location it will infiniscroll
// only if its parent is top
@nelix
nelix / stupid.rb
Created January 11, 2013 04:35
make urls match more.
def project_item(project)
url = project.devurl
if url.include?('*')
return [url] # User knows what they are doing
end
unless url.blank?
begin
uri = URI(project.devurl)

This is a request for comment - this is a proposed configuration API for the BugHerd Public Feedback and Sidebar

The BugHerd sidebar can be configured to override some of its default behaviour as well as display extra information in any tasks that you pass in from a configuration object called BugHerdConfig.

When setting up BugHerd for the first time, you probably already know you need to add the following code to your site:

  <script type="text/javascript">
    (function (d, t) {
      var bh = d.createElement(t), s = d.getElementsByTagName(t)[0];
@nelix
nelix / firefoxdespire.js
Created November 27, 2012 02:13
Why not just make the API magically more like the way I want to write things.
var workers = [];
PageMod({
include: "*",
contentScriptWhen: 'end',
contentScriptFile: data.url("content.js"),
attachTo: ["top", "existing"],
onAttach: function(worker) {
workers.push(worker);
worker.on('detach', function () {
log('worker detach');