Skip to content

Instantly share code, notes, and snippets.

@jamesjtong
jamesjtong / index.html
Created May 2, 2017 21:43
Video.js Example Embed // source http://jsbin.com/fiwutol
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Video.js Example Embed</title>
<link href="http://vjs.zencdn.net/5.19.2/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/5.19.2/video.js"></script>
</head>
//util
let cachedBrowser = '';
export function userAgent() {
return navigator.userAgent.toLowerCase();
}
export function browser() {
if (cachedBrowser.length > 0) {
return cachedBrowser;
class Account < ActiveRecord::Base
has_many :users
end
class User < ActiveRecord::Base
belongs_to :account
end
@jamesjtong
jamesjtong / changed and working
Created April 9, 2014 13:42
firefox not hoisting ngActiveResource properly?
angular.module('ActiveResource').provider('ARMixin', function () {
this.$get = function () {
return function (receiver, giver, excludeFunctions) {
function mixinProp() {
if (!receiver.hasOwnProperty(i)) {
(function () {
var local;
Object.defineProperty(receiver, i, {
enumerable: true,
INPUT STRINGs time= "2014-03-19T04:00:00.000Z" timezone=("Europe/Berlin")
CLOSEST THAT I HAVE GOTTEN
Time.zone.parse(time).in_time_zone(timezone).to_s
=> "2014-03-19 05:00:00 +0100"
DESIRED
=> "2014-03-19 06:00:00 +0000"
@jamesjtong
jamesjtong / gist:9348830
Last active August 29, 2015 13:57
json params passing in through advanced rest client of postman
class Api::V1::FightController < Api::BaseController
...
private
def permitted_params
params.permit(
{date: [
:timezone,
:start,
@jamesjtong
jamesjtong / sample.js
Created February 15, 2014 17:23
angular way?
$( "li" ).on( "mouseover", function() {
$(this).find($("button")).css("background-color", "yellow");
}
'use strict';
angular.module('ultimateJobApplierApp', [
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute',
'ngClipboard'
])
.config(function ($routeProvider) {
@jamesjtong
jamesjtong / gist:8533129
Created January 21, 2014 02:01
euler 10
def summation_of_primes(max)
array_of_nums = (0...max).to_a
array_of_nums[0] = nil
array_of_nums[1] = nil
#skip index 1 as thats number 1 and don't want to add that in later, 0 by default wont be added in
prod = 1
array_of_nums.each do |num|
next if num == nil
until prod > max
(2..max).each do |mult|
@jamesjtong
jamesjtong / gist:8527845
Created January 20, 2014 19:57
focus part is outputting value instead of item.label?
$(function() {
var availablePlayers = <%= raw @players_array.to_json %>;
$( ".nav-search" ).autocomplete({
source: availablePlayers,
// play with focus event later
focus: function( event, ui ) {
$( "textarea" ) = ui.item.label
}
select: function( event, ui ) {