Home Page
Archive > Posts > 2010 > November
Archive > Posts > 2010 > November

Warning: you do not have javascript enabled. This WILL cause layout glitches.

Something I feel JavaScript really got right
Language design is a PITA though... so bleh

One thing I always really miss when working in other dynamic languages that aren’t JavaScript is the ability to access known (non dynamic) members of an associative array/object/hash (called a hash from here on out) through just a single dot. This matches C’s syntax of accessing struct members, as opposed to being forced into using array syntax which is harder to read IMO in languages like PHP and Perl. For example...

Creating a hash in:
JavaScript:var Hash={foo:1, bar:2};
Perl:my %Hash=(foo=>1, bar=>2);
PHP:$Hash=Array('foo'=>1, 'bar'=>2);

Accessing a Hash’s member:
JavaScript:Hash.foo or Hash['foo']

The reason this is preferable to me is it can make code like the following
much more readable by turning it into the following
Studio Ghibli Film List
I definitely recommend most all of Miyazakis’ films

Here is another compilation list from a few years ago for reasons previously stated. This one is a color coded list of Studio Ghibli films (Hayao Miyazaki being a favorite of mine). A more comprehensive list can probably now be found on Wikipedia, but oh well.

Ghibli Films
Japanese TitleYearDirectorScreenplayAlso known as
Gedo senki2006Goro MiyazakiGoro MiyazakiTales from Earthsea
Taneyamagahara no yoru2006Kazuo OgaKenji Miyazawa
Hoshi wo katta hi2006Hayao MiyazakiHayao Miyazaki
Mizugumo monmon2006Hayao MiyazakiHayao Miyazaki
Yadosagashi2006Hayao MiyazakiHayao Miyazaki
Hauru no ugoku shiro2004Hayao MiyazakiHayao MiyazakiHowl’s Moving Castle
Inosensu: Kôkaku kidôtai2004Mamoru OshiiMamoru OshiiGhost in the Shell 2: Innocence
Kusoh no kikai-tachi no naka no hakai no hatsumei2002Hideaki AnnoHideaki AnnoThe Invention of Destruction in the Imaginary Machines
Ghiblies: Episode 22002Yoshiyuki MomoseManto Watanobe Ghiblies: Episode 2
Neko no ongaeshi2002Hiroyuki MoritaReiko YoshidaThe Cat Returns
Koro no dai-sanpo2002Hayao MiyazakiHayao Miyazaki
Mei to Koneko basu2002Hayao MiyazakiHayao MiyazakiMei and the Kitten Bus
Kujira tori2001Hayao MiyazakiHayao Miyazaki
Sen to Chihiro no kamikakushi2001Hayao MiyazakiHayao MiyazakiSpirited Away
Ghiblies: Episode 12000Ghiblies: Episode 1
Hôhokekyo tonari no Yamada-kun1999Isao TakahataIsao TakahataMy Neighbors the Yamadas
Mononoke-hime1997Hayao MiyazakiHayao MiyazakiPrincess Mononoke
Mimi wo sumaseba1995Yoshifumi KondoHayao MiyazakiWhisper of the Heart
On Your Mark1995Hayao MiyazakiHayao MiyazakiOn Your Mark
Heisei tanuki gassen pompoko1994Isao TakahataIsao TakahataPom Poko
Umi ga kikoeru1993Tomomichi MochizukiI Can Hear the Sea/The Ocean Waves
Kurenai no buta1992Hayao MiyazakiHayao MiyazakiPorco Rosso
Omohide poro poro1991Isao TakahataIsao TakahataMemories of Teardrops / Memories of Yesterday / Only Yesterday
Majo no takkyûbin1989Hayao MiyazakiHayao MiyazakiKiki’s Delivery Service
Hotaru no haka1988Isao TakahataIsao TakahataGrave of the Fireflies
Tonari no Totoro1988Hayao MiyazakiHayao MiyazakiMy Neighbor Totoro
Tenkû no shiro Rapyuta1986Hayao MiyazakiHayao MiyazakiLaputa: The Flying Island
Kaze no tani no Naushika1984Hayao MiyazakiHayao MiyazakiNausicaä
A weird thing happened today
I swear that’s never happened before!

As previously noted, I’ve been doing a lot of work for a project in mostly C# and dynamic languages. I had a weird experience today when moving back to the C++ portion of the project. As I was going through and reading my code to pick back up on the rewrite I was needing to do, I could feel my mind making a sudden paradigm shift in thought and it gave me a half a second dizzy spell. This shift wasn’t about language syntax or structure, as I’m constantly switching between dozens of languages for different projects I’m working on. However, I have very different programming styles and ways to do things between dynamic versus structured languages, and I had been so deep rooted in those other sections of the project in the past few days, my mind just hadn’t caught up to the code I was trying to read yet and had to tell me to hold on for a second while it reorganized so it could properly read the current type of code :-).

As a matter of fact... I think there are at least 11 “languages” I am having to use for this project (for sake of the count I am including scripting languages 0:-) ). C, C++, C#, Perl, PHP, SQL, Flash, JavaScript, HTML, CSS, and Bash scripting.

CSharp error failure
Why does Microsoft always have to make everything so hard?

I was running into a rather nasty .NET crash today in C# for a rather large project that I have been continuing development for on a handheld device that runs Windows CE6. When I was calling a callback function pointer (called a Delegate in .NET land) from a module, I was getting a TypeLoadException error with no further information. I started out making the incorrect assumption that I was doing something wrong with Delegates, as C# is not exactly my primary language ;-). The symptoms were pointing to the delegate call being the problem because the program was crashing during the delegate call itself, as the code reached the call, and did not make it into the callback function. After doing the normal debugging-thing, I found out the program crashed in the same manner every time the specific callback function was called and before it started executing, even if it was called in a normal fashion from the same class.

After further poking around, I realized that there was one line of code in the function that if included in any function, would cause the program to fail out on calling said function. Basically, resources were somehow missing from the compilation and there were no warnings anywhere telling me this. If I tried to access said resource normally, I was getting an easily traceable MissingManifestResourceException error. However, the weird situation was happening because I had the missing resource being accessed from a static member in another class. So here is some example code that was causing the problem:

public class ClassA
	public void PlaySuccess()
		//Execution DOES NOT reach here

public class Sound
	public static byte[] Success=MyResource.Success; //This resource is somehow missing from the executable
	public static byte[] Failure=MyResource.Failure;
	public static void Play(byte[] TheSound) { sndPlaySound(TheSound, SND_ASYNC|SND_MEMORY); }

ClassA Foo=new ClassA();
//Execution reaches here

Oh well, at least it wasn’t an array overrun, those are fun to track down :-).

Visual Studio IDE Tab Order
Microsoft fails at usability

I’ve been really annoyed for a while by the unintuitive IDE tab ordering in Visual Studio 2005+. When you type [shift+]alt+tab, you don’t get the next/previous tab in the list as would be the OBVIOUS way to do it (which probably all other IDEs do this right). No, it switches between tabs in an arbitrary hidden order related to the last acces order of the tabs.

Searching the internet for a solution to this was pretty fruitless, so I tried to tackle the problem myself. I dug through all the possible structures I could find in the Visual Studio IDE macro explorer, and was unfortunately unable to find where the tab order was kept in a window pane (if it is even accessible to the user). I thought I had the solution at one point, but realized it also just switches tabs in the order they were originally opened :-(. This is the VB macro code I came up with to do at least that, which uses “DTE.ActiveWindow.Document.Collection” for the tab-open order.

	 Public Sub TabDirection(ByVal Direction As Integer)
		  'Find the index of the current tab
		  Dim i As Integer
		  Dim Index As Integer
		  Dim Count As Integer
		  Count = DTE.ActiveWindow.Document.Collection.Count
		  For i = 1 To Count
				If DTE.ActiveWindow.Document.Collection.Item(i).ActiveWindow.Equals(DTE.ActiveWindow) Then Index = i
		  Next i

		  'Determine the new index
		  Index = Index + Direction
		  If Index > Count Then Index = 1
		  If Index = 0 Then Index = Count

		  DTE.ActiveWindow.Document.Collection.Item(Index).Activate() 'Activate the next tab in the proper direction
	 End Sub

	 Public Sub TabForward()
	 End Sub

	 Public Sub TabBackward()
	 End Sub
Ninja Turtles 2003 Episode List
A different type of compiling than the norm :-)

I got hit yesterday with a very time critical and large client project that will be taking up most all of my time over the next few weeks, so I may have to get in a lot of quick posts like this to keep up. :-\

A number of years ago I watched the new Teenage Mutant Ninja Turtle (2003) cartoon, and was shocked at how good it was. IMO there has been no other non-comedic American cartoon that has come out of its quality besides Avatar The Last Airbender (which is in its own league of quality for American cartoons). It was also saddening to me when watching the final (5th) season that a lot of those episodes hadn’t aired due to them being “too dark for kids” :-(. Also, for reference, I consider the show ended at 5 seasons. The “6th season” entitled “Fast Forward” is NOT the same show. I’d equate its quality to the Ninja Turtles cartoons of the 1980s, or perhaps worse.

Anywho, when I was giving the series’ DVDs to a friend, I felt the need to compile a list of the episodes, as they were made to be watched in a specific order, but were not aired or released (even remotely) in that proper order. There are some episodes repeated in the list as they were included on multiple DVDs. This information is probably much easier to find nowadays... but when I compiled it, it definitely wasn’t easy information to come by.

This list is ordered by DVD. The proper order to watch it in is found in the “Episode #” column.
DVD ## On DVDSeasonEpisode
in Season
Episode #Episode Name
11111Things Change
12122A Better Mousetrap
13133Attack of the Mousers
21144Meet Casey Jones
23166Darkness on the Edge of Town
31177The Way of Invisibility
32188Fallen Angel
4111010The Shredder Strikes, Part 1
4211111The Shredder Strikes, Part 2
4311212The Unconvincing Turtle Titan
5111313Notes from the Underground, Part 1
5211414Notes from the Underground, Part 2
5311515Notes from the Underground, Part 3
6111616The King
6211717The Shredder Strikes Back, Part 1
6311818The Shredder Strikes Back, Part 2
6411919Tales of Leo
7112020The Monster Hunter
7212121Return to New York, Part 1
7312222Return to New York, Part 2
7412323Return to New York, Part 3
8112424Lone Raph and Cub
8212525The Search for Splinter, Part 1
8312626The Search for Splinter, Part 2
912127Turtles in Space, Part 1: The Fugitoid
922228Turtles in Space, Part 2: The Trouble with Triceratons
932329Turtles in Space, Part 3: The Big House
942430Turtles in Space, Part 4: The Arena
1012531Turtles in Space Part 5: Triceraton Wars
1022632Secret Origins, Part 1
1032733Secret Origins, Part 2
1042834Secret Origins, Part 3
11221036The Ultimate Ninja
11321137Modern Love: The Return of Nano
11421844The Golden Puck
12121238What a Croc!
12221339Return to the Underground
12422147April’s Artifact
12522248Return of the Justice Force
1313153The Christmas Aliens
132111Things Change
13411010The Shredder Strikes, Part 1
14122349The Big Brawl, Part 1
14222450The Big Brawl, Part 2
14322551The Big Brawl, Part 3
14422652The Big Brawl, Part 4
15121440City at War, Part 1
15221541City at War, Part 2
15321642City at War, Part 3
15421945Rogue in the House, Part 1
15522046Rogue in the House, Part 2
16131365The Lesson
1633254Space Invaders, Part 1
1643355Space Invaders, Part 2
1653456Space Invaders, Part 3
1713557Worlds Collide, Part 1
1723658Worlds Collide, Part 2
1733759Worlds Collide, Part 3
1743860Touch and Go
17531264New Blood
18131971Reality Check
18232072Across The Universe
18332173Same As It Never Was
18432274The Real World, Part 1
18532375The Real World, Part 2
19132577Exodus, Part 1
19232678Exodus, Part 2
1934179Cousin Sid
1944482Dragon’s Brew
1954886Bad Day
20131466The Darkness Within
20231668The Entity Below
20332476Bishop’s Gambit
2044583I, Monster
20541290All Hallows Thieves
21231567Mission of Gravity
21331769Time Travails
2144280The People’s Choice
2154381Sons of the Silent Age
22131163Nobody’s Fool
22231870Hun on the Run
2234684Grudge Match
2244785A Wing and a Prayer
2254987Aliens Among Us
22641088Dragon’s Rising
23141189Still Nobody
23241391Samurai Tourist
23341492The Ancient One
23441593Scion of the Shredder
23541694Prodigal Son
23741896Trouble with Augie
23841997Insane in the Membrane
24142098Return of Savanti, Part 1
24242199Return of Savanti, Part 2
243422100Tale of Master Yoshi
244423101Adventures in Turtle Sitting
245424102Good Genes, Part 1
246425103Good Genes, Part 2
25151105Lap of the Gods
25252106Demons and Dragons
25353107Legend of the 5 Dragons
25454108More Worlds Than One
26155109Beginning of the End
26257111Membership Drive
26358112New World Order, Part 1
26459113New World Order, Part 2
271510114Fathers and Sons
272511115Past and Present
273512116Enter the Dragons, Part 1
274513117Enter the Dragons, Part 2
Second Life Research
More old research I never got around to releasing

Back in May of 2007 one of my friends got me onto Second Life, the first and only MMORPG I’ve touch since my Ragnarok days. While Second Life had a strong pull for me due to its similarities to The MetaVerse in Snow Crash, my favorite book, I was of course more drawn to playing with the Engine and seeing what I could do with it.

I felt no real need to delve into the code or packet level of the client as it was open source, so I stayed mostly on the scripting level side of things in the world. IIRC I did find at least a dozen major security holes, but I unfortunately cannot seem to find logs of my research :-(.

I do however remember at least 2 of the security holes I found:
  • While an avatar could not pass through solid walls normally, if an object was visible that allowed “sitting” beyond the walls, the user could issue the sit command on that object which transported the avatar past the barriers.
  • While there were optional restrictions on areas pertaining to if/where an object could be placed, once an object was placed somewhere, it could be “pushed” to almost any other location no matter the restrictions. When an object was pushed into another area beyond where it was placed, it was still inventoried as being in the originally placed location, but could interact with the world at the location it was actually at. Objects could even pass through solid barriers if the proper push velocities were given. The only way at the time to combat this was to have whole private islands as blocking anonymous objects. This security hole opened up multiple other security holes including:
    • If a user “sat” on the object, they could get to anywhere the object could.
    • These objects could be used to interact with the immediate world around them, including repeating private conversations in a private area.

I had also at the time planned on writing an application that allowed hijacking and reuploading any encountered texture or construct, which was trivial due to the open nature of the system. I never did get around to it for two reasons. First, I got distracted by other projects, and second, because it could have seriously destabilized the Second Life economy, which was built around selling said textures and constructs. I actually liked what Second Life was trying to accomplish and had no wish of making Linden Lab’s life harder or ruining the experiment in open economy.

I was however able to find a few pieces of my research and scripts that I figured I could post here. First, I do not recall what I did to find this, but the entire list of pre-defined “Last Names” was accessible, and IIRC the proprietary last names could be used for character creation if you knew how to access them (not 100% sure if this latter hack was available). Here was the list as of when I acquired it in 2007. I had the list separated into two columns, and I think they were “open” names and “proprietary” names. Each name is followed by its identifier.

Open Names
Congrejo(339), Spitteler(957), Boucher(1716), Kohime(2315), Korobase(2363), Bingyi(3983), Hyun(3994), Qunhua(4003), Yiyuan(4010), Nikolaidis(4032), Bikcin(4040), Laryukov(4112), Bamaisin(4127), Choche(4136), Ultsch(4140), Coage(4164), Cioc(4173), Barthelmess(4212), Koenkamp(4322), Daviau(4340), Menges(4345), Beaumont(4390), Lubitsch(4392), Taurog(4408), Negulesco(4418), Beresford(4466), Babenco(4468), Catteneo(4483), Dagostino(4509), Ihnen(4511), Basevi(4517), Gausman(4530), Heron(4533), Fegte(4535), Huldschinsky(4539), Juran(4543), Furse(4548), Heckroth(4550), Perfferle(4552), Reifsnider(4553), Hotaling(4559), DeCuir(4560), Carfagno(4561), Mielziner(4573), Bechir(4592), Zehetbauer(4615), Roelofs(4624), Hienrichs(4647), Rau(4654), Oppewall(4657), Bonetto(4659), Forwzy(4677), Repine(4680), Fimicoloud(4685), Bleac(4687), Anatine(4688), Gynoid(4745), Recreant(4748), Hapmouche(4749), Ceawlin(4758), Balut(4760), Peccable(4768), Barzane(4778), Eilde(4783), Whitfield(4806), Carter(4807), Vuckovic(4808), Rehula(4809), Docherty(4810), Riederer(4811), McMahon(4812), Messmer(4813), Allen(4814), Harrop(4815), Lilliehook(4816), Asbrink(4817), Laval(4818), Dyrssen(4819), Runo(4820), Uggla(4822), Mayo(4823), Handrick(4824), Grut(4825), Szondi(4826), Mannonen(4827), Korhonen(4828), Beck(4829), Nagy(4830), Nemeth(4831), Torok(4832), Mokeev(4833), Lednev(4834), Balczo(4835), Starostin(4836), Masala(4837), Rasmuson(4838), Martinek(4839), Mizser(4840), Zenovka(4841), Dovgal(4842), Capalini(4843), Kuhn(4845), Platthy(4846), Uriza(4847), Cortes(4848), Nishi(4849), Rang(4850), Schridde(4851), Dinzeo(4852), Winkler(4853), Broome(4854), Coakes(4855), Fargis(4856), Beerbaum(4857), Pessoa(4858), Mathy(4859), Robbiani(4860), Raymaker(4861), Voom(4862), Kappler(4863), Katscher(4864), Villota(4865), Etchegaray(4866), Waydelich(4867), Johin(4868), Blachere(4869), Despres(4871), Sautereau(4872), Miles(4873), Lytton(4874), Biedermann(4875), Noel(4876), Pennell(4877), Cazalet(4878), Sands(4879), Tatham(4880), Aabye(4881), Soderstrom(4882), Straaf(4883), Collas(4884), Roffo(4885), Sicling(4886), Flanagan(4887), Seiling(4888), Upshaw(4889), Rodenberger(4890), Habercom(4891), Kungler(4892), Theas(4893), Fride(4894), Hirons(4895), Shepherd(4896), Humphreys(4897), Mills(4898), Ireton(4899), Meriman(4900), Philbin(4901), Kidd(4902), Swindlehurst(4903), Lowey(4904), Foden(4905), Greggan(4906), Tammas(4907), Slade(4908), Munro(4909), Ebbage(4910), Homewood(4911), Chaffe(4912), Woodget(4913), Edman(4914), Fredriksson(4915), Larsson(4916), Gustafson(4917), Hynes(4918), Canning(4919), Loon(4920), Bekkers(4921), Ducatillon(4923), Maertens(4924), Piek(4925), Pintens(4926), Jansma(4927), Sewell(4928), Wuyts(4929), Hoorenbeek(4930), Broek(4931), Jacobus(4932), Streeter(4933), Babii(4934), Yifu(4935), Carlberg(4936), Palen(4937), Lane(4938), Bracken(4939), Bailey(4940), Morigi(4941), Hax(4942), Oyen(4943), Takacs(4944), Saenz(4945), Lundquist(4946), Tripsa(4947), Zabelin(4948), McMillan(4950), Rosca(4951), Zapedzki(4952), Falta(4953), Wiefel(4954), Ferraris(4955), Klaar(4956), Kamachi(4957), Schumann(4958), Milev(4959), Paine(4960), Staheli(4961), Decosta(4962), Schnyder(4963), Umarov(4964), Pinion(4965), Yoshikawa(4966), Mertel(4967), Iuga(4968), Vollmar(4969), Dollinger(4970), Hifeng(4971), Oh(4972), Tenk(4973), Snook(4974), Hultcrantz(4975), Barbosa(4976), Heberle(4977), Dagger(4978), Amat(4979), Jie(4980), Qinan(4981), Yalin(4982), Humby(4983), Carnell(4984), Burt(4985), Hird(4986), Lisle(4987), Huet(4988), Ronmark(4989), Sirbu(4990), Tomsen(4991), Karas(4992), Enoch(4993), Boa(4994), Stenvaag(4995), Bury(4996), Auer(4997), Etzel(4998), Klees(4999), Emmons(5000), Lusch(5001), Martynov(5002), Rotaru(5003), Ballinger(5004), Forcella(5005), Kohnke(5006), Kurka(5007), Writer(5008), Debevec(5009), Hirvi(5010), Planer(5011), Koba(5012), Helgerud(5013), Papp(5014), Melnik(5015), Hammerer(5016), Guyot(5017), Clary(5018), Ewing(5019), Beattie(5020), Merlin(5021), Halasy(5022), Rossini(5024), Halderman(5025), Watanabe(5026), Bade(5027), Vella(5028), Garrigus(5029), Faulds(5030), Pera(5031), Bing(5032), Singh(5033), Maktoum(5034), Petrov(5035), Panacek(5036), Dryke(5037), Shan(5038), Giha(5039), Graves(5040), Benelli(5041), Jun(5042), Ling(5043), Janus(5044), Gazov(5045), Pfeffer(5046), Lykin(5047), Forder(5048), Dench(5049), Hykova(5050), Gufler(5051), Binder(5052), Shilova(5053), Jewell(5054), Sperber(5055), Meili(5056), Matova(5057), Holmer(5058), Balogh(5059), Rhode(5060), Igaly(5061), Demina(5062)

Proprietary Names
ACS(1353), FairChang(1512), Teacher(2186), Learner(2213), Maestro(2214), Aprendiz(2215), Millionsofus(2746), Playahead(2833), RiversRunRed(2834), SunMicrosystems(2836), Carr(2917), Dell(3167), Reuters(3168), Hollywood(3173), Sheep(3471), YouTopia(3816), Hillburn(3817), Bradford(3820), CiscoSystems(3958), PhilipsDesign(3959), MadeVirtual(4205), DuranDuran(4210), eBay(4665), Vodafone(4666), Xerox(4667), TGDev(4668), Modesto(4669), Sensei(4670), Ideator(4671), Autodesk(4789), MovieTickets(4790), AvaStar(4791), DiorJoaillerie(4793), AOL(4795), Gabriel(4805), Tequila(5064), Loken(5065), Matlin(5066), GeekSquad(5067), Bradesco(5068), CredicardCiti(5069), PontiacGXP(5070), KAIZEN(5071), McCain(5072), Schomer(5074), Showtime(5075), OzIslander(5076), Meltingdots(5077), Allanson(5083), Sunbelter(5084), SaxoBank(5085), Esslinger(5086), Stengel(5087), Lemeur(5088), Tsujimoto(5089), KaizenGames(5090), Uphantis(5091), OurVirtualHolland(5092), McKinseyandCompany(5093), Lempert(5094), Affuso(5095), Gkguest(5096), Eye4You(5097), OShea(5098), Citibank(5099), Citicard(5100), Citigroup(5101), Citi(5102), Credicard(5103), Diners(5104), Citifinancial(5105), CitiBusiness(5106), BnT(5107), Yensid(5108), Helnwein(5111), Grindstaff(5112), Shirk(5113), SolidWorks(5114), Storm(5115), CarterFinancial(5116), Parkinson(5117), Lear(5118), FiatBrasil(5119), RossiResidencial(5120), Brooklintolive(5121), Calmund(5123), Briegel(5124), Herde(5125), Pfetzing(5126), Triebel(5127), Roemer(5128), Reacher(5129), Thomas(5130), Fraser(5131), Gabaldon(5132), NBA(5133), Accubee(5134), Brindle(5135), Searer(5136), Ukrop(5137), Ponticelli(5138), Belcastro(5139), Glin(5140), Rice(5141), DavidStern(5142), Totti(5144), onrez(5145), DeAnda(5146), Grandi(5147), Pianist(5148), osMoz(5149), PaulGee(5150)

The second piece I was able to find was a script I used to alert me via email whenever one of my friends signed on. I have unfortunately not tested this script before posting it as I no longer have Second Life installed or wish to waste the time testing it, but here it is none the less. ^_^;

//Users to watch
key DetectPersons=[ //List of UIDs of users to watch. (Real UIDs redacted)
    "fdf1fbff-f19f-ffff-ffff-ffffffffffff", //Person 1
    "f0fffaff-f61f-ffff-ffff-ffffffffffff" //Person 2

//Other Global Variables
integer NumUsers;
integer UsersParsed=0;
list UserNames;
list Status;

        NumUsers=llGetListLength(DetectPersons); //Number of users to watch

        //Get User Names
        integer i;
            llListInsertList(UserNames, [''], i);
            llListInsertList(Status, [0], i);
            llRequestAgentData(llList2Key(DetectPersons, i), DATA_NAME);

    dataserver(key requested, string data)
        //Find User Position
        integer i;
            if(llList2Key(DetectPersons, i)==requested)
                llListReplaceList(UserNames, [data], i, 1);

            state Running;

state Running

        llRequestAgentData(DetectPerson, DATA_ONLINE);

    dataserver(key requested, string data)
        string Message="The user you are watching '"+UserName+"' signed on at "+llGetTimestamp();
        llEmail(EMAIL_ADDRESS, "User Signed on", Message);

Of course all this research was from 2007 and I have no idea what is capable now. I do really hope though that they at least updated the client’s interface because it was incredibly clunky. Also, Second Life has always been a neat experiment, and I hope it still is and continues to keep doing well :-).

OpenSSH RSA Authentication public key file format
Curiosity as always

There are two primary authentication methods for logging onto an SSH server as a user. The first is password based authentication, and the second is public key authentication. The public/private RSA key pair for public key authentication can be created using OpenSSH’s “ssh-keygen” application.

I’m not going to go into the exact method on accomplishing this because instructions can be found on countless other places on the internet. However, I was curious yesterday as to what exactly was in the public key (.pub) files created by ssh-keygen, as the data payload was larger than I expected (2232 bits for a 2048 bit key). I couldn’t find documentation on this ANYWHERE on the internet, so I downloaded the OpenSSH source code and looked at the generation code of the files. The format of the files is as follows:

  • The public key files are ASCII based text files with each public key taking up exactly one line.
  • Each line is formatted with 2 pieces of data as follows:
  • KEY_TYPE is the type of public key, which in our case (and most cases nowadays) is “ssh-rsa”.
  • DATA_PAYLOAD contains the actual public key information encoded in base64 with the following format:
TypeByte lengthNameDescriptionDefault Value
unsigned int4KEY_TYPE_LENGTHLength of the next entry7
StringSee previousKEY_TYPESee abovessh-rsa
unsigned int4E_LENGTHLength of the next entry3
BigIntSee previousethis is the public key exponent in RSA65537
unsigned int4N_LENGTHLength of the next entryKEY_BIT_SIZE/8 (optional +1)
BigIntSee previousnthis is the “modulus for both the public and private keys” in RSAKey dependent

I also checked putty public key authentication files and they seemed to contain the exact same DATA_PAYLOAD.

Always make sure your envelope sender is correct
Otherwise things may not work as you expect

When you send an email there may be multiple fields in the email header that specify the email address that it came from and how to reply back to that address. Some of these are:

  • From: This is the field that the user sees in their email client as the "From" address. This field is the most easily (and most often) spoofable as you can put anything you want in this field and it doesn't change how the email is received or responded to. Most systems, in my experience, don't try to protect this field either.
  • Envelope sender: This is used internally by email software to see who the email was really from. Different systems (i.e. spam blockers) can use this field for different purposes.
  • Return path: This field specifies the email address to reply to when you click the "reply" button on your email client.

There can be multiple problems if the latter 2 field are not properly set. Some of these are:
  • Spam blockers may be more likely to identify the email as spam
  • The email might be sent from the wrong IP address. Exim (which cPanel uses by default) might be configured to check /etc/mailips to determine what IP address to send from depending on the domain of the envelope sender.
  • The recipient might reply to the wrong email address when replying to the email.

When sending an email from PHP via the mail function through Exim you can only manually set the "From" header field (of the three) through the "additional_headers" (4th) parameter. This might be possible to remedy on some systems however.

If your server is configured to allow it (it may require privileged user permission), you can pass to the "additional_parameters" (5th) parameter of the mail function the -f Exim option, which sets the envelope sender and return path. For example:

mail('example@gmail.com', 'This is an example', 'Example!', 'From: example@yourdomain.com', '-f example@yourdomain.com');

On a related security note, if you think an email may not be legitimate, don't forget to check the email headers by viewing the original email source. Our servers include many useful headers in emails to help combat fraud including (depending on circumstances) the account the email was sent from, the IP address it was sent from, if it was sent from PHP, and if so, the script it was sent from.

When a good idea is still considered too much by some

While UTF-8 has almost universally been accepted as the de-facto standard for Unicode character encoding in most non-Windows systems (mmmmmm Plan 9 ^_^), the BOM (Byte Order Marker) still has large adoption problems. While I have been allowing my text editors to add the UTF8 BOM to the beginning of all my text files for years, I have finally decided to rescind this practice for compatibility reasons.

While the UTF8 BOM is useful so that editors know for sure what the character encoding of a file is, and don’t have to guess, they are not really supported, for their reasons, in Unixland. Having to code solutions around this was becoming cumbersome. Programs like vi and pico/nano seem to ignore a file’s character encoding anyways and adopt the character encoding of the current terminal session.

The main culprit in which I was running into this problem a lot with is PHP. The funny thing about it too was that I had a solution for it working properly in Linux, but not Windows :-).

Web browsers do not expect to receive the BOM marker at the beginning of files, and if they encounter it, may have serious problems. For example, in a certain browser (*cough*IE*cough*) having a BOM on a file will cause the browser to not properly read the DOCTYPE, which can cause all sorts of nasty compatibility issues.

Something in my LAMP setup on my cPanel systems was removing the initial BOM at the beginning of outputted PHP contents, but through some preliminary research I could not find out why this was not occurring in Windows. However, both systems were receiving multiple BOMs at the beginning of the output due to PHP’s include/require functions not stripping the BOM from those included files. My solution to this was a simple overload of these include functions as follows (only required when called from any directly opened [non-included] PHP file):

/*Safe include/require functions that make sure UTF8 BOM is not output
where INCLUDETYPE is one of the following: include, require, include_once, require_once
An eval statement is used to maintain current scope

//The different include type functions
function safe_include($FileName)	{ return real_safe_include($FileName, 'include'); }
function safe_require($FileName)	{ return real_safe_include($FileName, 'require'); }
function safe_include_once($FileName)	{ return real_safe_include($FileName, 'include_once'); }
function safe_require_once($FileName)	{ return real_safe_include($FileName, 'require_once'); }

//Start the processing and return the eval statement
function real_safe_include($FileName, $IncludeType)
	return "$IncludeType('".strtr($FileName, Array("\\"=>"\\\\", "'", "\\'"))."'); safe_output_handler();";

//Do the actual processing and return the include data
function safe_output_handler()
	while(substr($Output, 0, 3)=='?') //Remove all instances of UTF8 BOM at the beginning of the output
		$Output=substr($Output, 3);
	print $Output;

I would have like to have used PHP’s output_handler ini setting to catch even the root file’s BOM and not require include function overloads, but, as php.net puts it “Only built-in functions can be used with this directive. For user defined functions, use ob_start().”.

As a bonus, the following bash command can be used to find all PHP files in the current directory tree with a UTF8 BOM:

grep -rlP "^\xef\xbb\xbf" . | grep -iP "\.php\$"

[Edit on 2015-11-27]
Better UTF8 BOM file find code (Cygwin compatible):
 find . -name '*.php' -print0 | xargs -0 -n1000 grep -l $'^\xef\xbb\xbf'
And to remove the BOMs (Cygwin compatible):
find . -name '*.php' -print0 | xargs -0 -n1000 grep -l $'^\xef\xbb\xbf' | xargs -i perl -i.bak -pe 'BEGIN{ @d=@ARGV } s/^\xef\xbb\xbf//; END{ unlink map "$_$^I", @d }' "{}"
Simpler remove BOMs (not Cygwin/Windows compatible):
find . -name '*.php' -print0 | xargs -0 -n1000 grep -l $'^\xef\xbb\xbf' | xargs -i perl -i -pe 's/^\xef\xbb\xbf//' "{}"