Skip to content

Instantly share code, notes, and snippets.

View kirkbackus's full-sized avatar

Kirk Backus kirkbackus

View GitHub Profile
@kirkbackus
kirkbackus / README.md
Last active October 1, 2019 22:31
MySQL Query For HeatMap

MySQL query that creates the data for a heatmap that takes in timezone. This will form the data necessary to produce a map like the Trulia Trends graph.

Initially I wrote a query that did not account for timezones

SELECT WEEKDAY(date_created)+1 as weekday, HOUR(date_created)+1 as hour, SUM(sub_total) as value FROM transaction WHERE voided = 0 GROUP BY weekday, hour;

This works great, if all of our customers lived in the Greenwhich Royal Observatory and shared that timezone. But as soon as we move outside that timezone, things get more complicated.

The second solution I came up with was to set an offset. And it looked like the following

@kirkbackus
kirkbackus / designer.html
Last active August 29, 2015 14:09
designer
<link rel="import" href="../topeka-elements/category-images.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<link rel="import" href="../paper-calculator/paper-calculator.html">
<polymer-element name="my-element">
@kirkbackus
kirkbackus / README.md
Last active August 29, 2015 14:10
Example on how to load a CSV into a MySQL table

#How to load a CSV into MySQL

This example uses the assumption that I have a table called verse whose schema is

describe verse;
+------------+---------------+------+-----+---------+-------+
| Field      | Type          | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| book_id    | int(11)       | NO   | PRI | NULL    |       |

| chapter | int(11) | NO | PRI | NULL | |

@kirkbackus
kirkbackus / README.md
Last active August 29, 2015 14:11
Orthographic Projection with Blip
@kirkbackus
kirkbackus / TestShallowCopy.java
Created July 8, 2015 14:52
Testing the shallow copy of an object to see if the second map keeps the original objects around after the first map is cleared. Turns out, the second map does in fact keep the objects around!
import java.util.Map;
import java.util.HashMap;
public class TestShallowCopy {
public static void main(String[] args) {
Map<String, Integer> a = new HashMap<String, Integer>();
a.put("TEST", 1);
Map<String, Integer> b = new HashMap<String, Integer>(a);
@kirkbackus
kirkbackus / README.md
Last active August 29, 2015 14:25
Google News Gist
String fileType = StringUtils.substringAfterLast(file.getOriginalFilename(), ".");
ImageWriter writer = ImageIO.getImageWritersByFormatName("jpeg").next();
ImageWriteParam param = writer.getDefaultWriteParam();
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionQuality(0.70f);
ByteArrayOutputStream os = new ByteArrayOutputStream();
writer.setOutput(os);
@kirkbackus
kirkbackus / sine.js
Created May 14, 2016 13:05
A simple implementation of a sine wave generator using the web-audio API
function Sine(ctx) {
this.sampleRate = ctx.sampleRate;
this.processor = ctx.createScriptProcessor(512,0,1)
this.processor.connect(ctx.destination);
this.offset = 0;
}
Sine.prototype.play = function(freq) {
this.processor.onaudioprocess = function(e) {
var out = e.outputBuffer.getChannelData(0);
@kirkbackus
kirkbackus / main.cpp
Created September 23, 2016 05:48
Enumerate all of the icons and their positions on your desktop
#include <iostream>
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <commctrl.h>
#include <winuser.h>
#include <tchar.h>
HWND GetDesktopListViewHWND()
{