Skip to content

Instantly share code, notes, and snippets.

View Rockncoder's full-sized avatar
💭
A coder's got to code

RocknCoder Rockncoder

💭
A coder's got to code
View GitHub Profile
@Rockncoder
Rockncoder / git-hub.services.ts
Last active April 5, 2017 00:42
Angular Service for calling GitHub Search API
import {Injectable} from '@angular/core';
import {Headers, Http, RequestOptions, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
@Injectable()
export class GitHubService {
// private baseUrl = 'https://api.github.com/search/';
@Rockncoder
Rockncoder / calculator.js
Created March 2, 2014 04:44
calculator method
rnc.calculator = function () {
rnc.Display.init($("#displayPanel")[0]);
$(".key").on('touchstart', function (event) {
var key = $(this).attr("data-rnc-tag"),
id = this.id;
// this is a performance boost
event.preventDefault();
event.stopPropagation();
@Rockncoder
Rockncoder / pages.js
Created November 8, 2013 14:44
Using deferred objects together in a when()
RocknCoder.Pages.splash = (function () {
return {
pageshow: function () {
RocknCoder.Game.dims = RocknCoder.Dimensions.get();
var context, loaderReady,
timerReady = $.Deferred(),
imageReady = $.Deferred(),
sounds = [
"sounds/83560__nbs-dark__ship-fire.wav",
@Rockncoder
Rockncoder / rncLoader.js
Created November 8, 2013 14:42
The new and improved RocknCoder loadAudioFiles
/**
* User: Troy
* Date: 11/4/13
* Time: 4:24 AM
*/
var RocknCoder = RocknCoder || {};
(function () {
@Rockncoder
Rockncoder / BufferLoader.js
Created November 8, 2013 13:48
The HTML5Rocks' BufferLoader class
function BufferLoader(context, urlList, callback) {
this.context = context;
this.urlList = urlList;
this.onload = callback;
this.bufferList = new Array();
this.loadCount = 0;
}
BufferLoader.prototype.loadBuffer = function(url, index) {
// Load buffer asynchronously
@Rockncoder
Rockncoder / pages.js
Created November 7, 2013 15:01
Using deferred objects
RocknCoder.Pages.splash = (function () {
return {
pageshow: function () {
// create our deferred objects
// the Ajax get methods return deferred objects
var timerReady = $.Deferred(),
spriteMapReady = $.get("1945.png"),
musicReady = $.get("DST-Afternoon.mp3");
// put our load screen up
@Rockncoder
Rockncoder / app.js
Created November 3, 2013 22:57
Simple mobile device detection and re-routing.
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http')
, hbs = require('hbs')
, path = require('path')
, app = express();
@Rockncoder
Rockncoder / edit-campaign.hbs
Created October 25, 2013 10:52
Using the option elment helper
<select id="goal2" name="goal2">
<option value="">Select goal</option>
<option {{option "cplp2" campaign.goal2}}>Cost per Lead</option>
<option {{option "cpap2" campaign.goal2}}>Cost per Acquisition</option>
<option {{option "cpip2" campaign.goal2}}>Cost per Inquiry</option>
</select>
@Rockncoder
Rockncoder / web.js
Created October 25, 2013 10:49
Generating the attributes of an option element.
// Render an option tag's value and selected attributes
hbs.registerHelper("option", function (current, field) {
current = hbs.Utils.escapeExpression(current);
field = hbs.Utils.escapeExpression(field);
var results = 'value="' + current + '" ' + (field === current ? 'selected="selected"' : "");
return new hbs.SafeString(results);
});
@Rockncoder
Rockncoder / MainActivity.java
Created September 15, 2013 22:28
Just three steps
private String getTwitterStream(String screenName) {
String results = null;
// Step 1: Encode consumer key and secret
try {
// URL encode the consumer key and secret
String urlApiKey = URLEncoder.encode(CONSUMER_KEY, "UTF-8");
String urlApiSecret = URLEncoder.encode(CONSUMER_SECRET, "UTF-8");
// Concatenate the encoded consumer key, a colon character, and the