Paul's Programming Notes     Archive     Feed     Github

UTDesign - Xbee Claims vs Reality

The picture above shows some research done by some UTD students for their UT Design program.

Their results showed the specs claimed by Xbee modules were far superior to reality. They said they experienced an overwhelming amount of noise at about half of the rated distance and both the peak and idle current ratings were inaccurate.

Raspberry Pi - Mining Bitcoins

Rather than letting my Raspberry Pi lay dormant in its cabinet at a data center, I've decided to use it for mining bitcoins.

I followed these instructions: http://www.youtube.com/watch?v=rrdzam7voOg

I'm using Deepbit as the pool, but I'm not 100% sure what a pool is or if there are better pools out there.

Update: In about 5 days, I have only mined 0.00003898 BTC.

Stop IE Alert Messages

The following snippet of Jquery will prevent alerts from showing in internet explorer:

if ($.browser.msie) { window.alert = function() { }; };

It detects if the browser is IE, then disables the alert function with a blank if it is IE. The alert happens only in IE, that's why it checks to see if the browser is IE.

I did this because there is some code I can't change on a sharepoint page which is causing an alert (which doesn't actually cause any real issues). Adding this code to the part of the page I can change will stop the error.

About the alert:
It says "Hit error fn!" and it happens in the following span after an ajax call fails: <span id="ctl00_LogUserActivity1">

It's definitely a hack, but it works so far.

Raspberry Pi Webserver w/ Wordpress Slow

I installed the LAMP stack on a Raspberry Pi, then moved a small Wordpress site to it. It then got plugged into a fast connection at a data center.

Before the move (shared hosting webserver at Siteground):

  • 1 second load times on the main page
After the move (Raspberry Pi):
  • 8-9 second load times on the main page
  • 5 second load times on single pages
The Pi does a good job at displaying static pages, but it does not run more intensive things like a CMS quickly enough.

LAMP Stack Ubuntu

It's crazy easy to install the LAMP stack on ubuntu with this command:

sudo apt-get install lamp-server^

SPJS Charts - Dynamically Select Filter Item

I've been using SPJS charts to make google charts with data from sharepoint lists. If you use a custom drop-down filter, you may want to dynamically select items in the drop-down like I did.

An example: You're using a drop-filter which filters the results by week, but you always want it to select last week.

Snippet:


function manualLoad(){
loadManually = false;
spjs_GenerateChart();

Date.prototype.getWeek = function() {
     var onejan = new Date(this.getFullYear(),0,1);
     var today = new Date(this.getFullYear(),this.getMonth(),this.getDate());
 var dayOfYear = ((today - onejan + 1)/86400000);
 return Math.ceil(dayOfYear/7)
};

$("#MyChart1_CustomFilterSelect_Week").val(new Date().getWeek()-1).change();
}

2nd Place - Ericsson & North Texas Food Bank Hackathon

The “Hackathon” was a programming competition sponsored by Ericsson to solve some of the North Texas Food Bank’s problems.

We made a scheduling system that allows people to see which days need more volunteers, then sign up to volunteer. The coolest part is that it would call people with a prerecorded message reminding them of their appointment.

Calculate Weeks In Sharepoint

=INT((Created-DATE(YEAR(Created),1,6)+(TEXT(WEEKDAY(DATE(YEAR(Created),0,1)),"d")))/7)+1

This is a modified version of this formula which didn't give me the correct week number (maybe due to regional settings?): http://lamahashim.blogspot.com/2009/10/sharepoint-calculated-field-week-number.html 

It matches the number of weeks calculated in excel and all the calculators I could find on the internet.

Update: I also needed to add a 0 before the "Week" if the number is less than 10, because it will cause an error in sorting otherwise.

Here's the formula to add a 0 if the number is less than 10:
=IF((INT((Date-DATE(YEAR(Date),1,6)+(TEXT(WEEKDAY(DATE(YEAR(Date),0,1)),"d")))/7)+1)<10,"0"&(INT((Date-DATE(YEAR(Date),1,6)+(TEXT(WEEKDAY(DATE(YEAR(Date),0,1)),"d")))/7)+1),(INT((Date-DATE(YEAR(Date),1,6)+(TEXT(WEEKDAY(DATE(YEAR(Date),0,1)),"d")))/7)+1))&" "

(Note: the &" " part forces it to be a string rather than a floating point value)

Impressive Javascript

https://github.com/mbostock/d3/wiki/Gallery

"D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful visualization components and a data-driven approach to DOM manipulation."