This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- A percent of total calculation using a joined, aggregated subquery | |
select state | |
, county | |
, 100 * population / state_population as pct_state_population | |
from census | |
join (select state, sum(population) state_population from census group by 1) using (state) | |
; | |
-- A percent of total calculation using a windowed aggregate | |
select state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{fmt, mem, slice, str}; | |
use std::ops::Deref; | |
const HEAP_STRING_FLAG: u8 = 1u8 << 7; | |
const MAX_INLINE_LENGTH: usize = 15; | |
#[repr(packed)] | |
#[derive(Default)] | |
pub struct CompactString { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sort(i,c) { | |
var o = [], r = i.length; | |
i.forEach(function(v) { | |
setTimeout(function() { | |
o.push(v); | |
if(0 === --r) { | |
c(o); | |
} | |
}, v); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am mhseiden on github. | |
* I am mhs (https://keybase.io/mhs) on keybase. | |
* I have a public key whose fingerprint is EA16 953E 006D 61B9 B6AC 8A3A 1B5A EC10 D7A9 50E4 | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function renderAudioData(canvas, data) { | |
// Grab handy variables with local names | |
var height = canvas.height; | |
var width = canvas.width; | |
var length = data.length; | |
var stepSize = width / length; | |
// Helper functions to make the index selection logic more readable further down | |
var xCoord = function(idx) { return stepSize * idx; }; | |
var xNext = function(idx) { return xCoord(idx + 1); }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In this gist, assume that we're using Chrome, and the following variables are in scope and have already been assigned to the following: | |
* | |
* var url = "http://upload.wikimedia.org/wikipedia/commons/b/be/Toccata_et_Fugue_BWV565.ogg"; | |
* var webaudio = new webkitAudioContext(); | |
* var renderCallback = function renderCallback(data) { return "render!"; } // a function which will render the given audio data on a canvas | |
*/ | |
// Fetch the data with an AJAX request | |
var xhr = new XMLHttpRequest(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Copyright (c) 2012 - Max Seiden <[email protected]> | |
Permission is hereby granted, free of charge, to any person obtaining a copy of | |
this software and associated documentation files (the "Software"), to deal in | |
the Software without restriction, including without limitation the rights to | |
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
the Software, and to permit persons to whom the Software is furnished to do so, | |
subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* NOTE - I haven't compiled this, so there may be small errors. | |
* However, the concepts shown are correct. | |
*/ | |
// In the *.h file | |
class MyClass; | |
class MyClass { | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Not an immediate vector | |
touch ‘safe_file.txt$(echo “Shell Injection” > safe_file.txt)’ | |
# Quite unsafe | |
touch “bad_file.txt$(echo “Shell Injection” > bad_file.txt)” |
NewerOlder