Skip to content

Instantly share code, notes, and snippets.

View spikeheap's full-sized avatar

Ryan Brooks spikeheap

View GitHub Profile
@cfjedimaster
cfjedimaster / gist:ee4a2fd935318e29bd5364d71ea221c1
Last active August 3, 2019 02:30
Bookmarklet to gray scale images w/o alt.
javascript:(function(){
var css = document.createElement("style");
css.type = "text/css";
css.innerHTML = "img[alt=\"\"],img:not([alt]){ filter:grayscale(100%) }";
document.body.appendChild(css);
})();
@robshep
robshep / docker_datasource.rb
Last active December 31, 2016 09:54
Use dockered databases for rails development
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
@derwiki
derwiki / README.md
Last active September 27, 2023 17:50
Ruby module that you can use in a `before_action` on sensitive controllers for which you'd like a usage audit trail

Adding an audit log to your Rails app

If you have any sort of administrative interface on your web site, you can easily imagine an intruder gaining access and mucking about. How do you know the extent of the damage? Adding an audit log to your app is one quick solution. An audit log should record a few things:

  • controller entry points with parameter values
  • permanent information about the user, like user_id
  • transient information about the user, like IP and user_agent

Using the Rails framework, this is as simple as adding a before_action to your admin controllers. Here’s a basic version that I’m using in production.

@parente
parente / aliases.sh
Created July 28, 2015 18:50
zsh aliases for docker and docker-machine
# Short for docker-machine
dm () {
docker-machine $@
}
# Switch docker pointer to another host (dmenv my_remote_host)
dmenv () {
eval "$(docker-machine env $1)"
}
# Short for docker
doc () {
@mrknmc
mrknmc / shopping.sh
Last active June 1, 2023 02:30
ASDA Groceries parsing
#!/usr/bin/env bash
### This only works assuming that you have all the necessary cookies in ./cookies.txt.
### I use this plugin: https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg
### Execute as follows: ./shopping.sh ./cookies.txt output.csv
# get last order id
order_id=$(curl -s -b $1 'https://groceries.asda.com/api/order/view?showmultisave=true&showrefund=true&pagenum=1&pagesize=25&requestorigin=gi' | jq -r '.orders | .[0] | .orderId')
# get url for last order
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing
@klange
klange / _.md
Last active December 2, 2023 20:36
It's a résumé, as a readable and compilable C source file. Since Hacker News got here, this has been updated to be most of my actual résumé. This isn't a serious document, just a concept to annoy people who talk about recruiting and the formats they accept résumés in. It's also relatively representative of my coding style.

Since this is on Hacker News and reddit...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later). My actual résumé is a good bit crazier.
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • Since people kept complaining, I've fixed the assignments of string literals to non-const char *s.
  • My use of type * name, however, is entirely intentional.
  • If you're using an older compiler, you might have trouble with the anonymous unions and the designated initializers - I think gcc 4.4 requires some extra braces to get them working together. Anything reasonably recent should work fine. Clang and gcc (newer than 4.4, at le
@nathansmith
nathansmith / web-design-development-learning-resources.md
Last active April 7, 2024 13:04
Resources for learning web design & front-end development
@schacon
schacon / gist:942899
Created April 26, 2011 19:19
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete