Skip to content

Instantly share code, notes, and snippets.

View said-and-done's full-sized avatar

Said Nuh said-and-done

  • @tv2 Editorial Dev Team
  • Copenhagen, Denmark
View GitHub Profile
# browser compatibility config
\Configure::write('Browser', array(
'minimum_requirement' => array(
'Chrome' => 36,
'Firefox' => 22,
'Safari' => 5,
'IE' => 9
)
#in your beforeFilter
$this->Crud->on('afterSave', function(CakeEvent $event){
if($event->subject->success){
pr($event->subject->id);
}
});
SELECT `Salesperson`.`id`,
`Salesperson`.`company_id`,
(SELECT Sum(project_item_allocations.amount /
project_items.salesperson_count)
FROM project_item_allocations
JOIN project_item_sellers
ON ( project_item_allocations.project_item_id =
project_item_sellers.project_item_id )
JOIN project_items
ON ( project_items.id = project_item_sellers.project_item_id )
@said-and-done
said-and-done / gist:9805586
Created March 27, 2014 11:33
compression ratio of JSON output: 95%
$ curl -s "https://codan.local../api/filtered.json" | gzip -> out.json; gzip --list out.json
compressed uncompressed ratio uncompressed_name
17.9 KB 381.4 KB 95.3% out.json
SELECT salesperson_id,
Sum(sold / salesperson_count) AS amount
FROM project_items
JOIN(SELECT allocation.project_item_id,
sold,
salesperson_id
FROM project_item_sellers
JOIN(SELECT project_item_id,
Sum(amount) AS sold
#antal dato
-----------------
75 8/9/2015
69 1/9/2015
63 26/5/2015
62 9/6/2015
54 15/9/2015
51 19/5/2015
42 12/5/2015
41 16/6/2015
@said-and-done
said-and-done / func.throttle.js
Created May 21, 2016 07:00
Call function at most once per every [wait] milliseconds. Useful for rate-limiting.
window.addEventListener('resize', throttle(resizer, 200));
function throttle(func, wait) {
// from underscore.js
var _now = Date.now || function() { return new Date().getTime(); },
context, args, result, timeout = null, previous = 0;
var later = function() {
previous = _now();
timeout = null;
result = func.apply(context, args);
var current = $('.mainNavTabs li.active a').attr('href').substr(1);
if(current == 'nutrients'){
var rows = 'Type\tgram';
var cols = ['Fedt', 'Protein', 'Kulhydrat (tilgængelig)', 'Kostfibre'];
$('tr.nutrient-row td').filter(function(){
return cols.indexOf($(this).text()) != -1;
}).each(function(){
var self = $(this);
var name = self.text();
var draw = function(cities){
var width = $(".linechart svg");
var svg = d3.select(".linechart svg");
var width = svg.node().width.baseVal.value;
var height = svg.node().height.baseVal.value;
var margin = {top: 20, right: 80, bottom: 30, left: 50},
width = width - margin.left - margin.right,
height = height - margin.top - margin.bottom,
var draw_table = function(data, caption){
var table = d3.select(".data-table").append("table");
var tbody = table.append("tbody");
var trows = tbody
.selectAll("tr")
.data(data)
.enter()
.append("tr");