Skip to content

Instantly share code, notes, and snippets.

View ikennaokpala's full-sized avatar
🎯
Focusing

Ikenna N. Okpala ikennaokpala

🎯
Focusing
View GitHub Profile
@casualjim
casualjim / gist:779445
Created January 14, 2011 10:19
Scalatra Socket.IO example
package org.scalatra
import socketio.{SocketIOServlet}
class SocketIOExample extends SocketIOServlet {
// overriden because otherwise you need a trailing slash for the root url
// prefer the freedom with or without root.
override def requestPath = {
val p = (Option(request.getPathInfo) getOrElse "").trim
@bruntonspall
bruntonspall / runtest.sh
Created January 20, 2011 15:43
How I run perf tests repeatably with records of what I did
#!/bin/bash
#Set Defaults
requests=${requests:=10}
threads=${threads:=1}
url=${url:=http://testserver/}
while getopts "r:t:u:h" Option
do
case $Option in
@ikennaokpala
ikennaokpala / login.js
Created February 13, 2011 14:14
Login status switch with Jquery Ajax
$(document).ready(function(){
$.each($.browser, function(i, val) {
if(i=="mozilla")
// alert("Ikenna Do stuff for firefox 3 Now now")
$('#header').before('<br/><br/>');
});
$("#loading").ajaxStart(function(){
$(this).append("<p><img src='/images/ajax-loader-2.gif' border='0' align='center' /></p>");
object AuthenticatedSession extends Loggable {
def logIn(credentialsOption: Option[Credentials]): Twitter = {
val (tw, credentials) = credentialsOption match {
case Some(cr) =>
(createTwitter(Some(cr)), cr)
case None =>
val requestToken = tw.getOAuthRequestToken
DesktopUtil.browse(requestToken.getAuthorizationURL)
(createTwitter(None), Dialog.showInput(null, "Enter the PIN from the Twitter authorization page in your browser",
"Enter PIN", Dialog.Message.Question, null, List[String](), "") match {
@wfaler
wfaler / NewWidgetForm.scala
Created April 3, 2011 17:52
NewWidgetForm.scala
import org.bowlerframework.view.squery.component.ValidationFeedbackPanel._
import org.bowlerframework.view.squery.Component
import org.bowlerframework.RequestScope
class NewWidgetForm extends Component{
val request = RequestScope.request
$("#errorPanel").contents = showErrorMessages
request.getSession.getValidatedModel match{
package com.mojolly.backchat
package web
class MySocketIOClient extends Client {
def receive = {
case Connected => {
}
case Message(msg) => {
//handlePlainTextMessage
package com.mojolly.backchat
package web
import org.scalatra.ScalatraServlet
import akka.actor.{Scheduler, Actor}
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
import org.atmosphere.cpr.BroadcastFilter.BroadcastAction
import org.atmosphere.cpr._
import org.atmosphere.util.XSSHtmlFilter
import collection.JavaConversions._
@casualjim
casualjim / rvmrc.sh
Created June 2, 2011 14:02
baseline rvmrc file
export RUBYOPT="rubygems"
rvm_install_on_use_flag=1
if [ -z $(rvm gemset list | grep virtmachines) 2> /dev/null ]; then
rvm ruby-1.8.7
rvm gemset create virtmachines
fi
rvm ruby-1.8.7@virtmachines
import sbt._
import Keys._
import org.sbtidea._
import SbtIdeaPlugin._
import Scope.{GlobalScope, ThisScope}
object BuildSettings {
val buildOrganization = "com.mojolly.backchat"
val buildScalaVersion = "2.9.0-1"
val buildVersion = "0.8.1-SNAPSHOT"
@ryanb
ryanb / spec_helper.rb
Created September 12, 2011 21:37
Use RSpec tags to add behavior around specs.
# Add this to your spec_helper.rb
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.around(:each, :vcr) do |example|
name = example.metadata[:full_description].downcase.gsub(/\W+/, "_").split("_", 2).join("/")
VCR.use_cassette(name, :record => :new_episodes) do
example.call
end
end
end