Skip to content

Instantly share code, notes, and snippets.

@krusynth
krusynth / nested_terms.php
Last active November 15, 2021 03:13
Quick and easy way to translate flat arrays into nested arrays in PHP.
<?php
/**
* Wrapper to get terms in a nested fashion.
* This gets a little complicated. Basically, we're creating a placeholder in
* $children to hold the child terms of each parent term. Then we create a
* reference to that element in the parent term. So nesting happens via magic.
*/
public function get_terms_nested($args)
{
$temp_terms = $this->get_terms($args);
@krusynth
krusynth / Maryland_g95-22F
Created October 11, 2013 13:47
Import file for Maryland
<?xml version="1.0" encoding="UTF-8"?>
<law>
<structure>
<unit label="article" identifier="g95" order_by="g95" level="1">g95</unit>
</structure>
<section_number>g95-22F</section_number>
<catch_line/>
<order_by>22F</order_by>
<text>
<section prefix="(a)">
@krusynth
krusynth / StatusMessages.md
Last active December 26, 2015 18:49
A short summary of the format of Status Messages.

#Status Messages

Status messages should be sent first thing in the morning, before the developer begins work. They should list all projects that they're currently actively involved with, as well as any side items that need to be addressed. For all tasks that fall outside the scope of project work, or for direct feedback, a Housekeeping list item is recommended.

Messages should list the projects with their statuses at the top of each message. Underneath, include short descriptions of the status of each. The whole message should generally only be 5-10 sentences at most - be clear and to the point as much as possible. Make sure to list any items that are blocking you from completing work, and feel free to call out the responsible party.

Each project should list its status, from the following available options: OK (everything is fine and progressing normally), HOLD (waiting on something out of your control), WARNING (something has gone wrong here), DANGER (something has gone VERY wrong here), `F

@krusynth
krusynth / tasklist.md
Created October 29, 2013 01:25
Task List Test
  • List I
    • Thing To Do
    • Another Thing To Do
    • This one has sub-items
      • HALP I AM BROKEN
      • ME TOO
    • Totes OK
  • List II
    • But if I do this
  • This works fine
@krusynth
krusynth / clearsolr.sh
Created November 8, 2013 15:43
Clear solr on localhost. Throw this in your .bash_profile or .bashrc and use `clearsolr *instancename*`
clearsolr() {
curl http://localhost:8983/solr/$1/update -H "Content-type: text/xml" --data-binary '<delete><query>*:*</query></delete>'
curl http://localhost:8983/solr/$1/update -H "Content-type: text/xml" --data-binary '<commit />'
curl http://localhost:8983/solr/$1/update -H "Content-type: text/xml" --data-binary '<optimize />'
curl http://localhost:8983/solr/$1/update -H "Content-type: text/xml" --data-binary '<commit />'
}
@krusynth
krusynth / class.Law.inc.php
Created December 30, 2013 00:30
Possible fix for linking to non-numbered sections.
<?php
/**
* The Law class, for retrieving data about individual laws.
*
* PHP version 5
*
* @license http://www.gnu.org/licenses/gpl.html GPL 3
* @version 0.8
* @link http://www.statedecoded.com/
@krusynth
krusynth / annotator-madison.js
Created January 9, 2014 19:06
Using binding to add parameters to a function
Annotator.Plugin.Madison = function(element, options){
this.options = options;
}
$.extend(Annotator.Plugin.Madison.prototype, new Annotator.Plugin(), {
events: {},
options: {},
pluginInit: function(){
this.annotator.viewer.addField({
load: load_fn.bind(this, user)
@krusynth
krusynth / governmentify.sh
Created March 8, 2014 19:27
Uses ImageMagick to read in a text file, transform it into an image, rotate it, add noise, and output as a pdf.
cat ./1-219.1.txt | convert \
-font Courier \
text:- \
-rotate `convert null: -format '%[fx:rand()*15-7]' info:` \
-attenuate 0.1247 +noise Gaussian \
-colorspace Gray \
1-219.1.pdf
@krusynth
krusynth / commits.py
Created March 20, 2014 15:09
Get most recent commit for every repo the user has access to.
from github import Github
from datetime import datetime
g = Github("user", "pass")
since = datetime(2014, 1, 1)
for org in g.get_user().get_orgs():
print org.name
@krusynth
krusynth / pyrax_content_disposition.py
Created April 1, 2014 20:35
Example of sending custom headers using Pyrax.
import config
import time
import uuid
import os
import pyrax
pyrax.set_setting("identity_type", "rackspace")
pyrax.set_setting("region", config.rackspace['API_REGION'])