Tag: Git

I have taken my original code I wrote for my SMF powered pastebin and rewrote this script. This was a massive rewrite from the original code and hopefully it works out well for anyone else who is looking into using it.

I wrote it so it should be plugable with different databases, user information and templating engines. The design was mostly to implant it into my mixed environment of SMF and WordPress, but also to make it robust so it could be used in other ways.

The source of the code is up on GitHub at https://github.com/jdarwood007/pastebin

Hello,
Originally I had wrote my original SMF Package Manager Generator a few years ago. It was sloppy coding, poor JavaScript and relied heavily on the server. Not my absolute best work, but was something I was proud on at the time from my efforts to dive into JavaScripting.

However, todays times are different. So with JQuery out there, I decided to take breaks from my projects for a couple hours for a few days and put forth a effort to rewrite this. Needless to say, I had the initial code wrote in only a few hours. My original script took me a few days alone. That didn’t count the package-info creator I made later which also took a while.

The new script attempts to rely all on JavaScripting via JQuery. It was a fun experience to build it this way. Although, because of JavaScript’s security measures, I couldn’t leave downloading the file outside of the server. So alas, I still have to process the actual download via the server. There is a work around with using Data URIs, however it didn’t provide the filename and sounds a bit flaky when the length of the url gets to be a bit long. I included both as a option though.

Oh and Its on github, because I see no reason to not share the code. Including the code I used to integrate it into my WordPress blog.

While working with a plugin for JQuery for week calendars. I came across a very annoying little bug. Using mouseover/out events did not seem to work correctly when hovering over the title and time. It just wouldn’t do what it should of.

Well after debugging and messing around for a while, I was able to figure out how to resolve this issue. In jquery.weekcalendar.js open up the file and locate:

JQuery has a nice plugin called . Very simple to use and I was able to integrate it into the database to handle pulling scheduling data. However I came across one issue. Reoccurring events.

Well after scrambling the web, I came to the conclusion that it wasn’t possible in the code by default. So away into the code I went. To say the least, my solution is nowhere near perfect nor does it allow for reoccurring events yet from different weeks or months. It was decided to take another course of action rather than trying to hack reoccurring events into the code. I just wanted to post what I had so far:

In jquery.weekcalendar.js we have this code:

1

//put back the initial start date

Now before this and the block of code before it, I added in:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

if($.isArray(recurring))

{

varcur_date=newDate();

varcur_dayofweek=cur_date.getDay();

varorg_start_date=calEvent.start.getDate();

varorg_end_date=calEvent.end.getDate();

for(vari=0;i<recurring.length;i++)

{

calEvent.readOnly=true;

varvalue=recurring[i];

varoffset=value-cur_dayofweek;

calEvent.start.setDate(cur_date.getDate()+offset);

calEvent.end.setDate(cur_date.getDate()+offset);

if(($weekDay=self._findWeekDayForEvent(calEvent,$weekDayColumns))){

self._renderEvent(calEvent,$weekDay);

}

}

calEvent.start.setDate(org_start_date);

calEvent.end.setDate(org_end_date);

calEvent.readOnly=false;

}

This lets me do reoccurring events for the current week. I am sure it could be greatly improved and somebody may be able to make it support multiple weeks.

In case anybody else wondered, this simply just needs a json array in the data of the weekday numbers (0-6). The key is recurring.

In moving my projects over to git, I stumbled across a troublesome issue. In one of my projects existed a folder along side trunk, tags and branches that had stuff I needed to be converted. However I wanted to convert these as individual git repositories.

So, after reading “git –help svn clone” and finding nothing to help me with this issue, I headed to the search engines. It took some time between search engines and asking some friends. As a note, Git 1.7 has sparse abilities, however I never got that far to try it out. I found out that git 1.6.4 included a new parameter which does the job just nicely.

This did the job exactly as I needed it to. It converted just the folder in the repository without so much of a complaint. Now that I review the git man page for svn, I do see I missed it.

When tracking multiple directories (using –stdlayout, –branches, or –tags options), git svn will attempt to connect to the
root (or highest allowed level) of the Subversion repository. This default allows better tracking of history if entire projects
are moved within a repository, but may cause issues on repositories where read access restrictions are in place. Passing
–no-minimize-url will allow git svn to accept URLs as-is without attempting to connect to a higher level directory. This option
is off by default when only one URL/branch is tracked (it would do little good).

I have my git repos cloned on my site. In order to keep my git viewer up to date, I need those clones to continue to be up to date.

Thankfully, there is a simple way to do this. git does have a –git-dir=/path, However this does not appear to work. You still need to change into the working directory in order to pull the updates. So after some work, I came up with this:

Shell

1

2

3

4

5

6

7

8

9

10

11

#!/bin/bash

FILES=/srv/git/*

forfin$FILES

do

if[-d$f]&&[-d$f/.git]

then

echo"Processing Git repository, $f"

cd$f

git--git-dir="$f/.git"pull-q

fi;

done

I simply add this as a cron tab, using > /dev/null to eat the output. However if an error occurs, I should receive a email with what exactly went on.