Skip to content

Instantly share code, notes, and snippets.

View ikennaokpala's full-sized avatar
🎯
Focusing

Ikenna N. Okpala ikennaokpala

🎯
Focusing
View GitHub Profile
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
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._
import java.text.SimpleDateFormat
import java.util.Date
class RichHumanDate(d:Long) {
def toHumanString() = {
val sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
val dt = new Date(d);
sdf.format(dt);
}
}
package com.mojolly.backchat
package web
class MySocketIOClient extends Client {
def receive = {
case Connected => {
}
case Message(msg) => {
//handlePlainTextMessage
@ikennaokpala
ikennaokpala / RandomTraversableOnce.scala
Created April 15, 2011 14:42 — forked from micrypt/Python's random.choice
Python's RandomTraversableOnce
import scala.util.Random
class RandomTraversableOnce[A](seq:TraversableOnce[A]){
def choice = seq.toList (new Random nextInt seq.size)
}
implicit def toRandomTraversableOnce[A](seq:TraversableOnce[A]) = new RandomTraversableOnce(seq)
type Transformer = Request => Request
object OptimusPrime extends Transformer { def apply(req: Request) = req }
object Megatron extends Transformer { def apply(req: Request) = throw new RuntimeException("Invalid operation!")}
@ikennaokpala
ikennaokpala / gist:1427178
Created December 3, 2011 13:54 — forked from GiaoGiaoCat/gist:1393770
Steps to install RVM + Ruby 1.9.2 + Rails + nginx + Passenger on CentOS (tested on v5.5)
# Steps to install RVM + Ruby 1.9.2 + Rails + nginx + Passenger on CentOS (tested on v5.5)
# Install git and curl, if not already installed
sudo yum install git
sudo yum install curl
# Create the rvm group and add any users who will be using rvm to the group
sudo su -
groupadd rvm
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do
@ikennaokpala
ikennaokpala / gemspec-usage.md
Created March 3, 2012 22:25 — forked from holman/gemspec-usage.md
test/spec/mini

Just install this in your apps like so:

gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'

Proposal for Improving Mass Assignment

For a while, I have felt that the following is the correct way to improve the mass assignment problem without increasing the burden on new users. Now that the problem with the Rails default has been brought up again, it's a good time to revisit it.

Sign Allowed Fields

When creating a form with form_for, include a signed token including all of the fields that were created at form creation time. Only these fields are allowed.

To allow new known fields to be added via JS, we could add: