Skip to content

Instantly share code, notes, and snippets.

View sleroux's full-sized avatar
:shipit:
on the loose

Stephan Leroux sleroux

:shipit:
on the loose
  • Shopify
  • Toronto, ON, Canada
View GitHub Profile
@sleroux
sleroux / gist:eb82bbbfb41e92747b09
Created May 21, 2015 17:55
To be lazy or not to be...
lazy var myLabel: UILabel = {
var temporaryLabel : UILabel = UILabel()
return temporaryLabel
}()
let testLabel: UILabel {
if !_testLabel {
_testLabel = UILabel()
}
return _testLabel!
func testFaviconTable() {
let files = MockFiles()
let db = BrowserDB(files: files)
let history = SQLiteHistory(db: db)
let bookmarks = SQLiteBookmarks(db: db, favicons: history)
let expectation = self.expectationWithDescription("First.")
func done() -> Success {
expectation.fulfill()
return succeed()
enum moz_sizeClass {
case Unknown
case XSmall
case Small
case Medium
case Large
case XLarge
case XXLarge
case XXXLarge
@sleroux
sleroux / gist:f5f47b8d17da0d4f87b2
Created June 15, 2015 19:12
TLD Parsing code from Gecko
// Finds the base domain for a host, with requested number of additional parts.
// This will fail, generating an error, if the host is an IPv4/IPv6 address,
// if more subdomain parts are requested than are available, or if the hostname
// includes characters that are not valid in a URL. Normalization is performed
// on the host string and the result will be in UTF8.
nsresult
nsEffectiveTLDService::GetBaseDomainInternal(nsCString &aHostname,
int32_t aAdditionalParts,
nsACString &aBaseDomain)
{
Storage!_TFFC7Storage12BrowserTable11updateTableFS0_FTCS_18SQLiteDBConnection4fromSi2toSi_SbU_FCS_5SDRowSS + 0x108
fp = 0x000000016fdfc850 lr = 0x00000001005b11f4
sp = 0x000000016fdfc840 pc = 0x00000001005c4c14
Found by: previous frame's frame pointer
11 Storage!_TTRXFo_oC7Storage5SDRow_oSS_XFo_oS0__iSS_ + 0x1c
fp = 0x000000016fdfcb00 lr = 0x000000010059a828
sp = 0x000000016fdfc860 pc = 0x00000001005b11f4
Found by: previous frame's frame pointer
12 Storage!_TZFC7StorageP33_3F4389F18684E136A114953F0C3F855C18FilledSQLiteCursor9getValuesU__fMGS0_Q__FTCS_P33_3F4389F18684E136A114953F0C3F855C17SQLiteDBStatement7factoryFCS_5SDRowQ_6statusROS_12CursorStatus13statusMessageRSS_GSaQ__ + 0x4e4
fp = 0x000000016fdfcbe0 lr = 0x000000010059a2a4
var data2xml = require("data2xml"),
key = 'splashScreen',
xmlObject = {},
imgPath = "dummyImage.png";
xmlObject[key] = {},
xmlObject[key]['image'] = [];
// Push 2 different images for each localization
xmlObject[key]["image"].push({
@sleroux
sleroux / frecency.md
Last active October 14, 2015 19:57
Frecency/Top Sites Optimization

The frecency query [1] we're making for our search recommendations/top sites is painfully slow. The query can up to a few seconds before completing. This is noticeable in places such as Top Sites where we run this query every time the user visits the panel. The items in Top Sites don’t render until the query completes. When taking a closer look at the query we're running to determine frecency, there are a number of factors which are causing it to be slow. Unlike desktop, frecency on mobile is calculated in real time instead of being pre-calculated. This results in a complex query that touches various tables with inner joins and computationally expensive ORDER/COALESCE operations. The query is then run on a potentially large data set since it touches the history table. In cases where a user has attached their FxA account, their desktop history will also be part of this.

After some discussion, there are 2 approaches we can take to optimize the way we handle frecency:

  1. Tweak/modify the existing query. Th
[10:58:21]: Successfully loaded custom action '/Users/sleroux/development/firefox-ios/fastlane/actions/checkout_git_branch.rb'.
[10:58:21]: Using branch: fluffyemily/fastlane-integration
[10:58:21]: Using build: 1
[10:58:21]: Using version: 1.0.0
[10:58:21]: Using username: <>
[10:58:21]: -------------------------------------------------
[10:58:21]: --- Step: Verifying required fastlane version ---
[10:58:21]: -------------------------------------------------
[10:58:21]: fastlane version valid
[10:58:21]: ------------------------------
@sleroux
sleroux / gist:3293e1973ecfba9cddc9
Created November 19, 2015 13:58
Fastlane Error Log 2
[08:28:06]: ------------------------------------
[08:28:06]: --- Step: increment_build_number ---
[08:28:06]: ------------------------------------
[08:28:06]: [SHELL COMMAND]: cd /Users/sleroux/development/firefox-ios && agvtool new-version -all 1
[08:28:07]: [SHELL]: Setting version of project Client to:
[08:28:07]: [SHELL]: 1.
[08:28:07]: [SHELL]:
[08:28:07]: [SHELL]: Also setting CFBundleVersion key (assuming it exists)
[08:28:07]: [SHELL]:
[08:28:07]: [SHELL]: Updating CFBundleVersion in Info.plist(s)...