Skip to content

Instantly share code, notes, and snippets.

View nettofarah's full-sized avatar

Netto Farah nettofarah

View GitHub Profile
@nettofarah
nettofarah / SegmentJestReporter.js
Created May 24, 2021 19:06
Send Jest test results into Segment
const fetch = require('node-fetch')
const ex = require('execa')
const writeKey = '<your_segment_write_key>'
const btoa = (val) => Buffer.from(val).toString('base64')
const getBranch = async () =>
(await ex('git', ['branch', '--show-current'])).stdout
async function increment(metric, value = 0, tags = []) {
const puppeteer = require('puppeteer')
const say = require('say')
async function find(page) {
await page.goto(
'https://www.tesla.com/inventory/new/my?arrangeby=relevance&zip=78724&range=200',
{
waitUntil: 'networkidle2',
}
)
async function onTrack(event, settings) {
if (event.event !== settings.eventName) {
return;
}
const product = event.properties.products[0];
const itemPurchased = `${product.brand} ${product.name}`;
const Body = `Thank you for purchasing ${itemPurchased} from our site. We will follow-up with the tracking details shortly.`;
const To = settings.twilioDestinationNumber;
/* @flow */
const Rx = require('rxjs/Rx');
const axios: axios = require('axios');
const requestStream: rxjs$Observable<string> = Rx.Observable.of(
'https://api.github.com/users'
);
const responseMetaStream: rxjs$Observable<any> = requestStream.map(
(requestUrl: string): rxjs$Observable<any> =>
@nettofarah
nettofarah / queries.graphql
Last active March 16, 2017 23:37
Sample Rubygems API using GraphQL
query {
rubygem: by_name(name: "rails") {
name
downloads
versions {
number
authors
}
}
@nettofarah
nettofarah / newrelic_instrumenter.rb
Created March 13, 2017 21:46
sample newrelic instrumenter for graphql-ruby
# NewRelic instrumenter for GraphQL-ruby
#
# In your controller:
# ::NewRelic::Agent.add_custom_attributes({
# user_id: @user.try(:id),
# query_string: @query_string,
# query_arguments: @query_variables
# })
#
# @document = self.class.trace_execution_scoped(["GraphQL#parse"]) do
@nettofarah
nettofarah / mergesort.js
Created February 12, 2017 02:40
Annotated Merge Sort in JavaScript
// Netto Farah
// Feb 11 2017
function mergeSort(array) {
// Clone array so we don't modify the input.
// This shouldn't be necessary in most cases
array = array.slice(0, array.length)
// msort is what we use to divide the problem
function msort(array, low, high) {
@nettofarah
nettofarah / bookmarklet.js
Created August 12, 2016 00:42
Real Balance (Pending + Current) for Mint.com
javascript:void(function() {
var pending = jQuery('.pending').find('td:last');
var values = Array.from(pending).map(td => jQuery(td).text().replace("$", "").replace("–", "-"));
values = values.filter(val => jQuery.trim(val)).map(parseFloat);
var pendingTotal = values.reduce((val, current) => val + current);
var currentTotalElement = jQuery('.account').first().find('.money').last();
var currentTotal = parseFloat(currentTotalElement.text().replace("–", "-").replace("$", ""));
var realTotal = currentTotal + pendingTotal;
@nettofarah
nettofarah / bookmarklet.js
Created August 11, 2016 05:45
Chase Credit Card Running Balance
javascript:void(function() {
var $ = window.jQuery;
function floatValue(element) {
var text = $(element).text().trim().replace(",", "").replace("$", "");
return parseFloat(text);
}
function updateCurrentBalance() {
var balanceElement = jQuery('div[data-attr="CREDIT_CARD_ACCOUNT.accountCurrentBalance"]');
@nettofarah
nettofarah / test_obfuscation.rb
Created December 4, 2015 21:25
Testing Polo with custom obfuscation strategy
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'