Skip to content

Instantly share code, notes, and snippets.

View penguinbroker's full-sized avatar

Dave Lee penguinbroker

  • Geneva Technologies, Inc
  • New York, NY
View GitHub Profile
@penguinbroker
penguinbroker / log.js
Created November 17, 2011 07:51
Paul Irish's logging solution
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if(this.console) {
arguments.callee = arguments.callee.caller;
var newarr = [].slice.call(arguments);
(typeof console.log === 'object' ? log.apply.call(console.log, console, newarr) : console.log.apply(console, newarr));
}
@penguinbroker
penguinbroker / gist:1378258
Created November 19, 2011 01:15
Paper.js hit test
hitTool = new paper.Tool();
hitTool.activate();
hitTool.onMouseDown = function (event) {
hitOptions = {
segments: true,
stroke: true,
fill: true,
tolerance: 5
};
hitResult = paper.project.hitTest(event.point, hitOptions);
@penguinbroker
penguinbroker / VideoChat.js
Created December 20, 2011 18:36
TokBox integrated chat lib
Chat = {
video: {
apiKey: 1935341,
subscribers: {},
publisherProps: {
width: 100,
height: 80,
name: tbMyName
},
subscriberProps: {
$(document).ready( function() {
var chatSession = <?=json_encode($tokbox)?>
, connected = 0
, session = null
, isPublishing = 0
, publisher = null
, numStreams = 0
, subscribers = {}
, publisherProps = {width: 100, height:80, name:tbMyName}
, subscriberProps = {width: 100, height:80};
var lastDrawing;
function save() {
var paths = [];
var path = paper.project.activeLayer.firstChild;
while (path) {
// store
segments = [];
foreach ( segment in path.segments ) {
@penguinbroker
penguinbroker / gist:6b88ed887f6dd168298f
Created January 22, 2015 23:52
clear bad phone numbers
val users = Await.result(ComponentRegistry.institutionUserDao.tableScan, 100.seconds)
users map { u =>
u.phoneNumber map { phoneNum =>
if (phoneNum.number.contains("region")) {
println("--")
println("fixing user")
println(u)
Await.result(ComponentRegistry.institutionUserService.update(u.copy(phoneNumber = None)), 5.seconds)
Thread.sleep(100)
}
search.cloudsearch.SearchDomains.cloudSearchAsync.truncate(search.UserDomain)
search.cloudsearch.SearchDomains.defineIndexFields(search.UserDomain)
search.cloudsearch.SearchDomains.startIndexing(search.UserDomain)
Await.result(ComponentRegistry.institutionDao.tableScan flatMap(ComponentRegistry.userSearch.seed), 1000 seconds)
@penguinbroker
penguinbroker / gist:8b94fd3db2f322e01821
Last active August 29, 2015 14:16
find broken sections
val sections = Await.result(ComponentRegistry.sectionDao.tableScan, 100.seconds)
sections map { section =>
val sectionId = section.getIdOrFail
val userSections = Await.result(ComponentRegistry.userSectionService.findInstructorsBySectionId(sectionId), 100.seconds)
val instructorIds = userSections.map( _.userId ).distinct
val allInstructors = Await.result(ComponentRegistry.institutionUserService.findByIds(instructorIds, section.institutionId), 100.seconds)
val instructors = allInstructors.filter(!_.isInactive)
instructors.find(_.getIdOrFail == section.instructorId) getOrElse {
println("--")
println("broken section")
val institution = Await.result(ComponentRegistry.institutionService.fetchById("8b5fc2a9-9055-46bc-9a83-1ff8c00b004a"), 10.seconds)
Await.result(ComponentRegistry.sectionEnrollmentService.enroll(institution, "74ee7c8f-f854-4b3e-8210-f13714e7110c", "14d3dca8-e277-415e-93f7-1601d6b9ec03", models.UserSectionRole.Instructor), 100.seconds)
@penguinbroker
penguinbroker / gist:bc4493e7e6def45da291
Last active August 29, 2015 14:18
clean slide uris
package migrations
import global.{ComponentRegistry, DaoRegistry}
import com.amazonaws.services.dynamodbv2.model.AttributeValue
import java.net.URI
import scala.concurrent.Await
import scala.concurrent.duration._
object SlideUriMigration extends DatabaseMigration with DaoRegistry {