Skip to content

Instantly share code, notes, and snippets.

View malchak's full-sized avatar

Michael Malchak malchak

View GitHub Profile
<script type="text/javascript">
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t,e){var n=document.createElement("script");n.type="text/javascript";n.async=!0;n.src="https://cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(n,a);analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.1.0";
analytics.load(SEGMENT_KEY);
analytic
@malchak
malchak / sl-analytics.md
Last active August 15, 2019 18:21
Anonymous Id Issue (analytics.js)

Segment script called on analytics.ready()

<script type="text/javascript">
  analytics.ready(function() {
    analytics.user().anonymousId('80242030-bf79-11e9-a17a-07af333ee672');    
  });
</script>
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@malchak
malchak / controllers.application.js
Created August 24, 2015 17:39
Query Params Array
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['filters'],
appName:'Ember Twiddle',
filters: [],
newFilter: '',
actions: {
@malchak
malchak / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@malchak
malchak / missing_num_array.rb
Last active September 28, 2020 19:00
Solutions to Find Missing Number in Array.
# Question:
# Suppose you have an array of 99 numbers.
# The array contains the digits 1 to 100 with one digit missing.
# Write four different algorithms to compute the missing number.
# Two of these should optimize for low storage and two of these should optimize for fast processing.
# (Keep in mind, there are no duplicates and the array is not already sorted.)
#######################################################
@malchak
malchak / deckOfCards.js
Created May 6, 2013 06:02
deckOfCards
var suits = ['Heart', 'Diamond', 'Club', 'Spade'];
var value = ['2','3','4','5','6','7','8','9','10','J','Q','K','A'];
function Card(num, suit) {
this.num = num;
this.suit = suit;
}
function Deck() {
this.cards = [];
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
// DRIVER CODE: Do **NOT** change anything below this point. Your task is to implement code above to make this work.
//------------------------------------------------------------------------------------------------------------------
@malchak
malchak / index.html
Created May 2, 2013 18:16 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>