Skip to content

Instantly share code, notes, and snippets.

View Sporky023's full-sized avatar

Luke Griffiths Sporky023

View GitHub Profile
function gmailAutoarchive() {
var delayDays = 2; // will only impact emails more than 48h old
var maxDate = new Date((new Date).getTime() - delayDays * 24 * 3600 * 1000);
// Get all the threads labelled 'autoarchive'
var label = GmailApp.getUserLabelByName("autoarchive");
var threads = label.getThreads(0, 400);
@Sporky023
Sporky023 / docker-cleanup-resources.md
Last active November 26, 2018 23:13 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@Sporky023
Sporky023 / bash_ps1_display_two_levels_of_pwd_context.sh
Created January 2, 2017 19:57
bash / PS1 / display two levels of pwd context
# thanks: https://muffinresearch.co.uk/showing-last-two-directories-of-pwd-in-bash-prompt/
function PWD {
pwd | sed 's/^\/Users\/<YOUR_USERNAME>/~/' | awk -F\/ '{print $(NF-1),$(NF)}' | sed 's/ /\//' | sed 's/~\/~/~/'
}
export PS1="\u\[\e[m\]:\[\e[36m\]\$(PWD)\[\e[m\] "
# backslash before $ tells it to run the function each time;
# else it is only run once and won't update as you switch directories

in your form.html.haml

  $(document).on('click', '.add_an_aol_field', function(){
    $aol_field = $('#aol_selector_template').html();

    $('.aol_fields').append($aol_field);
 });
@Sporky023
Sporky023 / gist:4195529
Created December 3, 2012 15:03
trial task for VA
"find potential suppliers for the pen thing"
* background:
* I want to sell the following product:
* a gag pen that cannot write
* both ends are the "inactive" end of the pen
* see these drawings: http://imgur.com/6DKTD
* Based on the simplicity of my design, I believe that any place which currently manufactures pens should be able to manufacture this, using existing parts on hand. However, I haven't had any luck with alibaba.com so far. I've gotten 3 quotes through alibaba.com, but they are very bad quality. I may want to contact these manufacturers more directly.
@Sporky023
Sporky023 / gist:3746265
Created September 18, 2012 22:14
admin_sends_offer_as_completely_new_company
Log in as admin
click "Admin"
click "Create New Company"
fill in company form
click "Save and add location"
fill in location form
click "Save and add another location"
fill in location form
click "Save and add an employee"
fill in employee form
@Sporky023
Sporky023 / openbay_state_transitions.txt
Created September 9, 2012 23:41
openbay state transitions
Non-indented lines show actions take by users.
Indented lines show resulting states of various records.
Everything is from SP's point of view:
[P, C, or S] (P)ending, (C)losed, (S)ettled. Which list to show Offer on under "Manage Offers"
[A, C] (A)ctive, (C)losed. Which list to show Service Request on.
SCENARIO 1: VO withdraws offer
VO: create service_request_1
service_request_1: 'Active, N days remaining' - A
@Sporky023
Sporky023 / gist:3611463
Created September 3, 2012 18:01
traceroute to PT assets
~ $ traceroute cdn3-pivotaltracker.pantherssl.com
traceroute: Warning: cdn3-pivotaltracker.pantherssl.com has multiple addresses; using 66.114.52.15
traceroute to cdn-pivotaltracker.pantherssl.com.cdngc.net (66.114.52.15), 64 hops max, 52 byte packets
1 172.16.0.2 (172.16.0.2) 1.155 ms 0.616 ms 0.849 ms
2 core-1.cictr.com (204.9.220.34) 1.350 ms 0.918 ms 0.883 ms
3 ge-0-3-2-7-3600-sur01.cambridge.ma.boston.comcast.net (107.0.92.209) 3.757 ms 3.509 ms 4.271 ms
4 te-0-9-0-6-ar01.needham.ma.boston.comcast.net (68.85.106.29) 3.121 ms 5.876 ms 3.666 ms
5 he-2-9-0-0-cr01.newyork.ny.ibone.comcast.net (68.86.90.57) 11.355 ms 18.006 ms 10.235 ms
6 xe-7-0-3.edge1.newyork2.level3.net (4.71.186.41) 7.679 ms 7.572 ms 10.289 ms
7 vlan51.ebr1.newyork2.level3.net (4.69.138.222) 7.741 ms 7.456 ms 7.547 ms
BACKGROUND:
We're changing the offer form a bit to have a new set of fields for each line item in the offer. Therefore we need to change the set of columns in the database table that stores these line items. Old data will need to be modified to fit the new format. This document outlines an algorithm for modifying the old data into the new format.
EXISTING COLUMNS
* description
* quantity
* part_price (unit price per part)
ActionView::Template::Error (undefined method `fed_date' for nil:NilClass):
3: = @state.name
4: (&#8358; #{number_with_delimiter(@fa, :delimiter => ',')})
5: .small
6: = "#{@state.federal_allocations.order("fed_date DESC").last.fed_date.strftime("%m-%Y")} - #{@state.federal_allocations.order("fed_date DESC").first.fed_date.strftime("%m-%Y")}"
7: .clear
8:
9: #text
app/views/projects/modal.haml:6:in `_app_views_projects_modal_haml___1854547266735518192_2509573200'
app/controllers/projects_controller.rb:9:in `block (2 levels) in modal'