Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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:6304a583a3f021282d31
Created October 23, 2014 16:41
replace the <input type="text"> with a nice button
<div class='file-input'>
<input type="file" id="theSvgFile" name="theSvgFile" class="hide ie_show" onchange="readURL(this);"/>
<div class="btn btn-default" onclick="$(this).parent('.file-input').find(':file').click();">Upload SVG</div>
<span class="file-display"></span>
<script type="text/javascript">
var readURL = function (input) {
if (input.files && input.files[0]) {
$(input).parent('.file-input').find('.file-display').text(input.files[0].name);
}
}
@daohodac
daohodac / index.html
Last active August 29, 2015 14:08
intercalate an element <g> with jQuery
<!DOCTYPE html>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
var intercalateFails = function() {
var zoomParentId = "zoom_anim_parent_bbsmashed";
var gId = "#zoom_anim";
$(gId).parent().append($("<g id='"+zoomParentId+"'>"));
var that = $(gId).detach().appendTo("#"+zoomParentId);
};
@daohodac
daohodac / index.html
Last active August 29, 2015 14:09
dynamically add some simple force directed labels to elements
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<svg width="300px" height="200px">
<rect stroke="black" fill="lightgrey" x="0" y="0" width="300px" height="200px"/>
</svg>
<button id="addBtn">ADD</button>
<script type="text/javascript">
console.log("init all")
@daohodac
daohodac / gist:2509fc371e756bac19f4
Created January 16, 2015 15:39
fleet-matrix example
//on récupere les A380 uniquement parmi les fwots
var a380s = _. where(FWOTS, {type: "A380"});
//on rajoute les colonnes et on les décrit
var columns = [
{ name: "SD-01",
domain: [0,10],
colors: ['black', 'darkorange'],
formula: function(data) {
return _.where(data,{APUSDID: "1"}).length;
@daohodac
daohodac / index.html
Last active August 29, 2015 14:16
a game to learn multiply tables
<!DOCTYPE html>
<meta charset="utf-8">
<style>
text {
text-anchor: middle;
font-family: verdana;
}
.selX {
@daohodac
daohodac / index.html
Last active August 29, 2015 14:17
WILCO A300 impact-mapping cluster layout
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node circle {
fill: #fff;
stroke: steelblue;
stroke-width: 1.5px;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.