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 / 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>");
@ikennaokpala
ikennaokpala / countries.js
Created February 22, 2011 15:25
Countries Drop down
var all_countries = ['---Select a country---','United Kingdom','United States','Canada', 'Austria', 'Belgium', 'Bulgaria', 'Cyprus', 'Czech Republic', 'Denmark', 'Estonia', 'Finland', 'France', 'Germany', 'Greece', 'Hungary', 'Italy', 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Netherlands', 'Poland', 'Portugal', 'Romania', 'Slovakia', 'Slovenia', 'Spain', 'Sweden', 'Honduras','El Salvador','Haiti','Jamaica', 'Guyana','Afghanistan', 'Albania', 'Algeria', 'Andorra', 'Angola', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Australia', 'Azerbaijan', 'Bahamas', 'Bahrain', 'Bangladesh', 'Barbados', 'Belarus', 'Belize', 'Benin', 'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Brazil', 'Brunei Darussalam', 'Burkina Faso', 'Burma', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Central African Republic', 'Chad', 'Chile', 'China', 'Colombia', 'Comoros', 'Congo', 'Democratic Republic of the Congo', 'Costa Rica', 'Côte d\'Ivoire', 'Croatia', 'Cuba', 'Djibouti', 'Dominica', 'Dominican Republ
-- DELIMITER $$
DELIMITER $$
-- DROP PROCEDURE IF EXISTS UPDATE_COL_COUNT $$
DROP PROCEDURE IF EXISTS UPDATE_COL_COUNT $$
CREATE PROCEDURE UPDATE_COL_COUNT(NEW_TAXO_ID INTEGER, NEW_COUNT INTEGER)
BEGIN
SET @dyn_sql=CONCAT(
'UPDATE ' , 'WP_TERM_TAXONOMY',
' SET ' , 'COUNT', ' = ?
WHERE ' , 'TERM_TAXONOMY_ID', ' = ?');
@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();