Skip to content

Instantly share code, notes, and snippets.

@daohodac
daohodac / index.html
Created October 22, 2014 09:22
D3: intercalate a <g> between parent and selected element
<!DOCTYPE html>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v3.js"></script>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(function() {
var blink = function(what) {
what.transition().duration(1000).attr('opacity', 0).transition().duration(500).attr('opacity', 1).each('end', function() {
blink(what)
@daohodac
daohodac / gist:7823245
Created December 6, 2013 12:50
plugin sublime text 2 to copy all the files in a directory in to a remote one after each save (hardcoded items)
import sublime_plugin, os
class RemoteEdit(sublime_plugin.EventListener):
def on_post_save(self, view):
remote = { "/Users/dao/Documents/work/IT/tests/d3": "/usr/bin/scp '$1' [email protected]:/home/hodac/bin/fleet/d3/" }
for dirname, target in remote.iteritems():
if view.file_name().startswith( dirname ):
target = target.replace( "$1", view.file_name() )
target = target.replace( "$2", view.file_name()[len(dirname):] )
@daohodac
daohodac / gist:5671039
Created May 29, 2013 15:09
get the last components which belongs to a holder that is in the five last by category
select * from cl_component
where holder_id in(
SELECT r1.id
FROM cl_checklist r1
LEFT OUTER JOIN cl_checklist r2
ON (r1.aircraftcid = r2.aircraftcid AND r1.checklistcid = r2.checklistcid AND r1.created < r2.created)
WHERE r1.dtype='Report' AND r1.checklistcid='ef0fd241-9a6c-43f0-8074-4ca310108ff5' AND r1.aircraftreg='F-GFKF'
GROUP BY r1.id, r1.serverLastUpdate, r1.created
HAVING COUNT(*) < 5
ORDER BY r1.id DESC