Skip to content

Instantly share code, notes, and snippets.

View michaelchadwick's full-sized avatar
🤘

Michael Chadwick michaelchadwick

🤘
View GitHub Profile
@michaelchadwick
michaelchadwick / soundcloud-get-user-info-and-track-embeds.js
Created January 30, 2015 20:09
SoundCloud Basic User and Track Embeds
// SoundCloud API INITIALIZE
SC.initialize({
client_id: 'CLIENT_ID',
redirect_uri: 'REDIRECT_URI'
});
$(document).ready(function() {
// grab the connect click, get info and track embeds
$('a.connect').click(function(e) {
@michaelchadwick
michaelchadwick / save_load.rb
Last active August 29, 2015 14:27
Save/Load module
#!/usr/bin/env ruby
require 'io/console'
class SaveLoad
SAVE_DATA_FILE = 'save.conf'
attr_accessor :data_changed
def initialize
self.data_changed = false

Keybase proof

I hereby claim:

  • I am michaelchadwick on github.
  • I am michaelchadwick (https://keybase.io/michaelchadwick) on keybase.
  • I have a public key ASAERnh7ODVR9NHo3la-BRDflXdKJjEGX633I6A_ivMWcgo

To claim this, I am signing this object:

@michaelchadwick
michaelchadwick / equalHeights.js
Created May 1, 2017 22:37
Dynamically resize elements based on tallest one
// dynamically size elements based on tallest one
equalheight = function(container) {
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPostion = 0;
$(container).each(function() {
$el = $(this);
@michaelchadwick
michaelchadwick / service.ts
Created May 10, 2017 22:57
async service
// src/app/service.ts
import { Injectable } from '@angular/core';
import { Headers, Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';
@Injectable()
export class MyService {
private headers = new Headers({'Content-Type': 'application/json'});
private apiUrl = 'http://localhost:8000'; // URL to web api
@michaelchadwick
michaelchadwick / service.spec.ts
Last active May 11, 2017 15:51
async service testing
// src/app/service.spec.ts
//import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs/Rx';
import { TestBed, inject, async } from '@angular/core/testing';
import { MockBackend, MockConnection } from '@angular/http/testing';
import { Http, BaseRequestOptions, Response, ResponseOptions, RequestMethod } from '@angular/http';
import 'rxjs/add/observable/from';
import 'rxjs/add/observable/throw';
@michaelchadwick
michaelchadwick / app.component.html
Created June 14, 2017 16:31
angular 2 testing - AppComponent template
...
<div class="jumbotron">
<div class="container">
<div class="col-sm-8 col-sm-offset-2">
<router-outlet></router-outlet>
</div>
</div>
</div>
@michaelchadwick
michaelchadwick / dave.service.ts
Created June 14, 2017 21:10
angular 2 testing - DaveService
import { Injectable } from '@angular/core';
import { Headers, Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import { devlog } from '../_helpers/devlog';
@Injectable()
export class DaveService {
@michaelchadwick
michaelchadwick / app.module.ts
Created June 14, 2017 21:11
angular 2 testing - AppModule
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { Routes, RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { DaveService } from './_services/dave.service';
import { HomeComponent } from './home/index';
@michaelchadwick
michaelchadwick / home.component.ts
Last active June 14, 2017 21:12
angular 2 testing - HomeComponent
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Response } from '@angular/http';
import { Subscription } from 'rxjs/Subscription';
import { DaveService } from '../_services/dave.service';
import { devlog } from '../_helpers/devlog';
@Component({
moduleId: module.id,
templateUrl: './home.component.html',