Skip to content

Instantly share code, notes, and snippets.

View OrenBochman's full-sized avatar
🏠
Working from home

Oren Bochman OrenBochman

🏠
Working from home
  • WMF
  • 15:50 (UTC +03:00)
View GitHub Profile
@OrenBochman
OrenBochman / cleanUrl
Created August 22, 2016 11:19
grm_cleanUrlTracker
/**
* Cleans the URL based on the preferences set in the configuration options.
* set config queries from {{url_cleaner_conf}}
* custom dim storage not implemented - since it is more easily stored using a dataleyer var
* to setup combine set page path in with gtm tags
*/
function() {
var opts = { 'stripQuery' : true, 'queryDimensionIndex': null, 'indexFilename' : 'index.html', 'trailingSlash': 'remove'};
if( {{url_cleaner_conf}} != null)
opts = JSON.parse( {{url_cleaner_conf}} );
@OrenBochman
OrenBochman / console_table.js
Last active September 15, 2016 11:25
debug data propeties in console
var result = Object.getOwnPropertyNames(data).filter(/./.test.bind(new RegExp("^g")));
console.table(data,Object.getOwnPropertyNames(data).filter(/./.test.bind(new RegExp("^g"))));
@OrenBochman
OrenBochman / introrx.md
Created November 4, 2016 07:55 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@OrenBochman
OrenBochman / 0_BQ_description.md
Last active October 25, 2023 15:54
Big Query for GA analytics

BigQuery for Google Analytics

No metrics in

Self Joins

  • Cross Join example
  • Inner Join example

joins can be inefficent - they can require moving lots of data around and increase the data process from n to n * n

@OrenBochman
OrenBochman / TagSpider.py
Created January 9, 2017 11:02 — forked from cspenn/TagSpider.py
GA/GTM Tag Checker in Python and Scrapy
# -*- coding: utf-8 -*-
# Copyright Christopher S. Penn, 2016 | cspenn.com | @cspenn
# This software is licensed under the GNU General Public License, version 3.0.
# Absolutely no warranty or support is provided.
# Run at your own risk.
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
@OrenBochman
OrenBochman / LogUtil.java
Created March 9, 2017 20:46 — forked from dors/LogUtil.java
Cool log util for Android apps that prints each log with the thread, class name and method name from which the log was made
import android.util.Log;
import java.text.MessageFormat;
/*
* Copyright 2015 Dor Sakal
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@OrenBochman
OrenBochman / _sql_reshaping_triplets_to_to_columns.md
Last active November 13, 2018 07:55
sql reshaping: converting a narrow triplets store to a wide table and combining related attributes and concatenating multiple entries within cells

SQL reshaping:

  • converting a narrow triplets store to a wide table and combining related attributes and concatenating multiple entries within cells

What happening in the first solution:

  • we create a row per country via group by.
  • then we create each column by an aggragate on a case.
  • the case could be eliminated using a sub query
  • also we concat result using a mysql extension GROUP_CONCAT() or PostgreSQL, SQL Server 2017 and Azure SQL ext STRING_AGG()
@OrenBochman
OrenBochman / _sql_removing_nulls.md
Last active November 13, 2018 07:47
sql null in sub_query

Filter out the winners

Notes

  • in this interview question the bad query fails beacasse of null values in the races table.
  • adding a where not field is null exludes the nulls and allows the function to work correctly
  • using a subquery within the where clause based on a forieng key is like an inner join.
  • using a negation of the above produces a filter of non winner.
  • cheking null is done using IS not =
@OrenBochman
OrenBochman / Limit.sql
Created July 18, 2017 07:00
the 10th best row
SELECT Salary FROM
(
SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT 10
) AS Emp ORDER BY Salary LIMIT 1;
@OrenBochman
OrenBochman / _ledger.md
Last active July 18, 2017 07:23
sql_ledger

[SQL Fiddle][1]

MySQL 5.6 Schema Setup:

CREATE TABLE Clients
    (client_id int NOT NULL AUTO_INCREMENT,
     client_name VARCHAR(25),
     PRIMARY KEY(client_id)

)