Skip to content

Instantly share code, notes, and snippets.

function pairedChartColors(count) {
pairedSchemes = {3:["#a6cee3","#1f78b4","#b2df8a"],4:["#a6cee3","#1f78b4","#b2df8a","#33a02c"],5:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99"],6:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c"],7:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f"],8:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00"],9:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6"],10:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a"],11:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99"],12:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"]}
return pairedSchemes[count];
}
@zyphlar
zyphlar / pdo.php
Created March 11, 2016 00:21
pdo example
<?php
//..
$foo = "foofoo";
$bar = "barbar";
$conn = new PDO('mysql:host=yourserverip;dbname=yourdatabasename', 'username', 'password');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@zyphlar
zyphlar / googlevisualr-helper.rb
Created July 11, 2012 23:14
Helper and model methods for creating GoogleVisualr charts
# This is a Rails helper for generating a single chart for a column from a data set.
# blood_tests is the data set, and column_name is the column from the set to use.
# It calls generate_chart_row for each record, passing the column_name argument.
# It also does some stuff with vertical axis labels and chart options.
def generateChart(blood_tests, column_name)
data_table = GoogleVisualr::DataTable.new
@zyphlar
zyphlar / symfony-post-controller-hook.php
Created February 25, 2016 19:22
after-controller-response hooks in Symfony2
<?php
public function myPostControllerFunction($someObject) {
$dispatcher = $this->get('event_dispatcher');
$logger = $this->get('logger');
$dispatcher->addListener('kernel.terminate', function ($event) use ($logger, $someObject) {
$logger->warning('This log entry was generated after Kernel Terminate and was passed an object of class: '.get_class($someObject));
});
}
<?php
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\AbstractType;
class MyFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
@zyphlar
zyphlar / refile_bootstrap_progress_bars.1.js
Last active February 10, 2016 17:44
Adding Bootstrap Progress Bars to Refile with Multiple File Upload Enabled
// refile upload progress
var uploadsSuccessful = 0;
var uploadsFailed = 0;
var uploadsCompleted = 0;
var uploadsTotal = 0;
var progressBarParent = null;
$(document).on("upload:start", "form", function(e) {
$(this).find("input[type=submit]").attr("disabled", true);
@zyphlar
zyphlar / pr-template.md
Created January 5, 2016 19:14
Pull Request Template for Git-Splainin

What does this PR do?

How should this be manually tested?

What are the relevant story, task, or ticket links?

What are the deployment instructions (if any?)

@zyphlar
zyphlar / pfsense-pinger-cron.txt
Last active December 30, 2015 18:19
Pinging a subnet, logging it to a file, and viewing that file in pfSense.
# Either put the line below at /etc/crontab or in the Cron service package in the webui.
* * * * * root /usr/bin/nice -n20 /root/pinger.sh 192.168.1. >> /tmp/ping.log
@zyphlar
zyphlar / nmap.sh
Last active December 30, 2015 18:19
Monitoring Network Performance with NMap and pfSense
nmap -v -sn 192.168.1.0/24 -oX /tmp/nmap-ping.log --append-output
class Project
has_many :project_items
has_many :features, through: :project_item
has_many :milestones, through: :project_item
# stuff
end
class ProjectItem