Skip to content

Instantly share code, notes, and snippets.

View p5150j's full-sized avatar
🎯
Focusing

Patrick p5150j

🎯
Focusing
View GitHub Profile
---add the gem to your gem file---
gem 'jasmine', :group => [:development, :test]
---bundle it in your rails app---
bundle
---generate spec dir, /helpers, /support---
rails g jasmine:install
---create a test name with _spec.js ending in your spec dir root and save---
@p5150j
p5150j / gist:5775245
Created June 13, 2013 16:36
jasmine jquery
/*!
Jasmine-jQuery: a set of jQuery helpers for Jasmine tests.
Version 1.5.2
https://github.com/velesin/jasmine-jquery
Copyright (c) 2010-2013 Wojciech Zawistowski, Travis Jeffery
Permission is hereby granted, free of charge, to any person obtaining
@p5150j
p5150j / gist:5776472
Last active December 18, 2015 11:29
jasmine jquery global stage set up
//set up you test name and any testible fixtures/vars=code for testing
describe("global set up", function () {
//store your jquery in a var
var elem;
beforeEach(function () {
//all your jquery
elem = $('<div class="a" id="some-id"><p></p></div>')
});
//test yo stuff homie
@p5150j
p5150j / gist:5845564
Created June 23, 2013 16:20
rails ajax connection to api
jQuery.ajaxSetup({
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
})
$(function(){
$.ajaxSetup({
'beforeSend': function( xhr ) {
var token = $('meta[name="csrf-token"]').attr('content');
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
@p5150j
p5150j / gist:6147847
Created August 3, 2013 20:19
node async get json
var http = require('http')
function fetchVideosJson() {
console.log('getting json for videos');
http.get({ host: 'http://levels.reachenginestage.com/videos.json', path: '/?delay=2000' }, function(res) {
console.log('bLamo! did you blink? cuz here is your data homie');
}).on('error', function(e) {
console.log("There was an error" + e);
});
# Timecode burn with ffmpeg
# ffmpeg must be configured with --enable-libfreetype
# box=1 - tells ffmpeg to draw a box around the text
# boxcolor - format is 0xRRGGBB[AA]
ffmpeg -i video.mov -vcodec libx264 -cmp 22 -vf "drawtext=fontfile=DroidSansMono.ttf: timecode='09\:57\:00\:00': r=23.976: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000099" -y output.mov
@p5150j
p5150j / CarrierWave.rb
Last active December 23, 2015 00:19
CarrierWave initializer to store to s3
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => 'baz', # required
:aws_secret_access_key => 'foo', # required
# :region => 'eu-west-1', # optional, defaults to 'us-east-1'
# :host => 's3.example.com', # optional, defaults to nil
# :endpoint => 'https://s3.example.com:8080' # optional, defaults to nil
#
}
function restoreOrderSidebar() {
var cookie = $.cookie('cookie_sidebar');
if (!cookie) return;
var SavedID = cookie.split('|');
for ( var u=0, ul=SavedID.length; u < ul; u++ ){ SavedID[u] = SavedID[u].split(',');}
for (var Scolumn=0, n = SavedID.length; Scolumn < n; Scolumn++) {
for (var Sitem=0, m = SavedID[Scolumn].length; Sitem < m; Sitem++) {
$("#sortable").eq(Scolumn).append($("#sortable").children("#" + SavedID[Scolumn][Sitem]));
}
}
<accordion>
<accordion-group heading="Static Header, initially expanded" is-open="true">
This content is straight in the template.
</accordion-group>
<accordion-group heading="{{group.title}}" ng-repeat="group in groups">
{{group.content}}
</accordion-group>
<accordion-group heading="Dynamic Body Content">
<p>The body of the accordion group grows to fit the contents</p>
<button class="btn btn-default btn-sm" ng-click="addItem()">Add Item</button>
@import url("icons.css");
@import url("grid.css");
@import url("typography.css");
@import url("tables.css");
@import url("forms.css");
@import url("buttons.css");
@import url("navigation.css");
@import url("indicators.css");
@import url("modal.css");
@import url("media.css");