Skip to content

Instantly share code, notes, and snippets.

View ikennaokpala's full-sized avatar
🎯
Focusing

Ikenna N. Okpala ikennaokpala

🎯
Focusing
View GitHub Profile
@ikennaokpala
ikennaokpala / UPDATE_COUNT_RUBY_STYLE.rb
Created March 4, 2011 16:37
UPDATE_COUNT_RUBY_STYLE
require 'rubygems'
require 'mysql'
mysql = Mysql.real_connect("localhost", "root", "pass", "db")
results = mysql.query("select wp_term_taxonomy.term_taxonomy_id as taxo_id, count(*) as count from wp_term_taxonomy
left join wp_term_relationships on wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id
where (wp_term_taxonomy.parent = 6 or wp_term_taxonomy.term_id = 6) group by term_id;")
results.each { |e|
mysql.query("UPDATE WP_TERM_TAXONOMY SET COUNT = #{e[1]} WHERE WP_TERM_TAXONOMY.TERM_TAXONOMY_ID = #{e[0]};")
}
@ikennaokpala
ikennaokpala / PHOTO_FEED.js
Created March 6, 2011 16:01
ALBUM_PHOTO_FEED
$(function() {
// var pathArray = window.location.pathname.split("/")
console.log(GetAlbums.getUrlVars()["name"])
// if (typeof GetAlbums.getUrlVars()["name"] === "undefined")
// window.location.pathname = "/Stuff"
//for(i=0; i<= pathArray.length; i++){
// }
@ikennaokpala
ikennaokpala / contact-form.js
Created March 9, 2011 10:00
ajax contact-form.js
/* jquery code for Contact form overlay starts here */
var location = window.location;
$("#cpage").val(location);
// console.log("Current href: "+location);
var email = $("a[href^='mailto:']").text();
$("a[href^='mailto:']").attr('id', 'messagewindow');
$("a[href^='mailto:']").attr('href', '#');
if(email == ""){
@ikennaokpala
ikennaokpala / getUrlVars.js
Created March 12, 2011 04:00
Get url parameter values
// http://localhost:8080/index?id=546&name=kengimel
var id = myVars.getUrlVars()["id"];
var name = myVars.getUrlVars()["name"];
console.log("ID is currently this value: "+id);
console.log("Name is currently this value: "+name);
var myVars= {
getUrlVars: function() {
@ikennaokpala
ikennaokpala / jquery_firebug.js
Created March 15, 2011 09:17
Load jQuery File to Firebug Console
var s = document.createElement('script');
s.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js');
document.body.appendChild(s);
s.onload=function(){
// alert("hello")
//Js code
};
void(s);
@ikennaokpala
ikennaokpala / multiplication_table.scala
Created March 17, 2011 11:13
Multiplication Table with Scala
// Taken from the programming in Scala book second edition page 138
// Returns a row as a sequence
def makeRowSeq(row: int) =
for (col <- 1 to 10) yield {
val prod = (row * col).toString
val padding = " " *(4 - prod.length)
padding + prod
}
@ikennaokpala
ikennaokpala / striphtml.js
Created March 22, 2011 16:43
Strip html tags
jQuery.fn.stripTags = function() {
return this.replaceWith( this.html().replace(/<\/?[^>]+>/gi, '') );
};
$("#any").stripTags();
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);
}
}