HN user

scraft

610 karma
Posts5
Comments105
View on HN

Small defensive suggestion: I’d usually define both the enabled and disabled versions as statement-like macros:

  #ifdef MGBALOG
  #define mgbalog(level, format, ...) \
      do { _mgbalog(level, format, ##__VA_ARGS__); } while (0)
  #else
  #define mgbalog(level, format, ...) \
      do { } while (0)
  #endif
For the exact usage shown here, "mgbalog(...);" will mostly work with the empty replacement-list version, since it just leaves a bare ";". So this is not a guaranteed bug.

The reason I prefer the "do { } while (0)" form is that it keeps the macro structurally equivalent to a single statement in both debug and release builds. With the empty disabled macro, this:

  if (failed)
      mgbalog(ERROR, "failed");
becomes:
  if (failed)
      ;
That is valid C, but it can trigger empty-body / suspicious-semicolon warnings, for example GCC’s "-Wempty-body", which matters if the project builds with "-Wextra" or warnings-as-errors.

It also means the enabled case is already set up correctly if the macro later grows beyond a single function call. For example, if you later add another statement to the macro:

  #define LOG(x) printf("log\n"); printf("%s\n", x)

  if (failed)
      LOG("failed");
  else
      recover();
then the expansion breaks because the "else" no longer attaches to the intended "if".

So in this specific case the empty macro is probably fine for ordinary "mgbalog(...);" calls, but wrapping both versions in "do { } while (0)" is the more conventional and future-proof C macro shape.

But this process, including sending smaller items first etc sounds like it would have taken longer than what the OP did? And the OP was trying to do it quickly to tie in with the beginning of the semester?

I saw similar engraved and then inked onto wooden boards at a restaurant, sadly, despite the error handling, 3 out of 4 I tried were not scannable, the 1 I did manage to scan to me to a reviews site for the restaurant (where a lot of reviews said they struggled to make the QR work - likely not the feedback the restaurant wanted)! I guess it kept me entertained whilst waiting for the bill.

GTFOBins 3 months ago

The last time I used anything similar to this was circa 1995 at secondary school, using Windows 3.11 computers, that has been set up so you could only launch a small number of authorised applications.

One of those was Word.

In Word you could write macros and use shell to launch other applications.

Suddenly the locked down computer that exposed a handful of applications could run anything (well anything a Windows 3.11 machine in 1995 could run).

It was quite exciting at the time, I don't feel like I have hit the same sort of issues since. Ocassionally I see people say that some touch screen information displays (in shops/shopping centres etc) have ways to escape from kiosk mode (locked to an app) so you can use them for anything, I guess that is similar.

On the PS2 there was a very small memory area, called the scratchpad, that was very quick to access, the rough idea on the PS2 was to DMA data in and out of the scratch pad, and then do work in the data, without creating contention with everything else going on at the same time.

In general most developers struggled to do much with it, it was just too small (combined with the fiddlyness of using it).

PS2 programmer's were very used to thinking in this way as it's how the rendering had to be done. There is a couple of vector units, and one of them is connected to the GPU, so the general structure most developers followed was to have 4 buffers in the VU memory (I think it only had 16kb of memory or something pretty small), but essentially in parallel you'd have:

1. New data being DMAd in from main memory to VU memory (into say buffer 1/4). 2. Previous data in buffer 3/4 being transformed, lit, coloured, etc and output into buffer 4/4. 3. Data from buffer 2/4 being sent/rendered by the GPU.

Then once the above had finished it would flip, so you'd alternate like:

Data in: B1 (main memory to VU) Data out: B2 (VU to GPU) Data process from: B3 (VU processing) Data process to: B4 (VU processing)

Data in: B3 Data out: B4 Data process from: B1 Data process to: B2

The VU has two pipelines running in parallel (float and integer), and every instruction had an exact number of cycles to process, if you read a result before it is ready you stall the pipeline, so you had to painstakingly interleave and order your instructions to process three verts at a time and be very clever about register pressure etc.

There is obviously some clever syncing logic to allow all of this to work, allowing the DMA to wait until the VU kicks off the next GPU batch etc.

It was complex to get your head around, set up all the moving parts and debug when it goes wrong. When it goes wrong it pretty much just hangs, so you had to write a lot of validators. On PS2 you basically spend the frame building up a huge DMA list, and then at the end of the frame kick it off and it renders everything, so the DMA will transfer VU programs to the VU, upload data to the VU, wait for it to process and upload next batch, at the end upload next program, upload settings to GPU registers, bacially everything. Once that DMA is kicked off no more CPU code is involved in rendering the frame, so you have a MB or so of pure memory transfer instructions firing off, if any of them are wrong you are in a world of pain.

Then throw in, just to keep things interesting, the fact that anything you write to memory is likely stuck in caches, and DMA doesn't seem caches, so extra care has to be taken to make sure caches are flushed before using DMA.

It was a magical, horrible, wonderful, painful, joyous, impossible, satisfying, sickening, amazing time.

Actually, in special relativity, if you could somehow travel at light speed, your own proper time wouldn’t pass at all. The journey would be instant from your perspective. You’d experience zero time between departure and arrival.

That’s not just "relativistically instant", that’s literally instant in your frame. The time dilation becomes total at light speed, and length contraction collapses the entire distance in the direction of travel to zero.

Now, it’s true we can’t really assign a rest frame to a photon, so this is a thought experiment. But if you extrapolate the math, the conclusion holds: no time passes for something traveling at light speed.

if i am not writing or editing a file, just doing nothing, then why FS breaks?

For a few reasons, but the most common is that when you write a file, you 'fwrite' operation doesn't typically immediately write blocks to the disk, instead it gets written to caches that will be written to disk in due course. Changes to the disk, tables with crucial data, etc again are just updated in memory, and written to the disk at a 'sensible' time. It's possible that you aren't actively performing operations to modify the disk, but various previous changes are sitting in memory waiting to be synced. If you kill the power then these changes aren't flushed so you can end up with corruption/filesystem problems. The main reason things work this way is for performance.

I use Copy Me That (website/app), I am not sure if it has all the features you want, but I use it for storing recipes in a "no nonsense" format and can share recipes with friends/family. I get the impression if you pay you can do shopping lists etc but I haven't used that side of it to comment.

I heard this £30 saving stuff on the radio this morning, and it made me shake my head a little. I remember when I got a socket adapter that measures power consumption, and I went around checking all my appliances, eager to find out which are drawing lots of power, excited at the money savings. Started with my old, huge, plasma TV, that is the best part of 15 years old - surely chugging loads of power in standby? Nope, next to nothing. Monitors, same. Network switches, same. Essentially I didn't find anything in my property that was doing anything unexpected. Having hot water (which I get via electricity as my flat doesn't have gas) for a single day will use up more energy than I'd save unplugging all my devices. Similar for heating (again, electricity based) on a colder day in winter would cost more than all the standby devices.

I remember a long time ago (25 years?) someone 'invented' a device where you plug your TV into it, and it has an IR receiver to go with it, you program it to respond to your TVs power button (on the remote control), and then when you go to put your TV into standby, the plug then turns off too, and when you switch it on it does the opposite. At the time it was being touted as the money saver, and I got the impression (although never actually tested!) TVs back then did draw a lot in standby, so this 'invention' was a legitimately good one. But it didn't seem to really take off, I am assume because standby was rapidly implemented in a way where there is such minimal electrical draw that it would be pointless.

I used Keepass + Dropbox (to sync database). This set up was suggested to me when I joined a company that requires complex unique passwords for all sign ups. At the time I didn't think too much about it, but this thread has made me thankful I was guided in this direction.

I don't have experience of any other password management software, so I certainly can't compare and contrast. But I will say Keepass + Dropbox has worked flawlessly for me across desktop, laptop and mobile. The biggest inconvenience I have had is things like manually typing in a Netflix password into a Smart TV when on holiday (just takes time with long passwords with capitals, lowercase, numbers and symbols).

Budgeted £42k ended up costing £60k for us both. I know some people which did it for a lot less (like half) but we didn't want to miss out on various things as we went.

We stayed in a lot of hostels, along with some guest houses, Airbnbs, hotels but the majority of the time it was something in the cheaper end of the spectrum.

We initially budgeted £10 food, £5 drink and £5 activities per day, and kept quite a lot of records at time, but ultimately we just ended up feeling "it is what it is". We made the active decision to just make the most of the trip and overspend. For a reasonable number of days we could average out towards our budget but we found fairly regularly there were bigger expenses for activities which would blow the budget and we neither wanted to miss them or do nothing for the next fortnight! Once you have committed so much, it sort of feels like it is better to commit a bit more and make it awesome (£60k spent on awesome seemed better than £42k spent on okay).

Before leaving I ran a couple of companies, one which employed 12 people and another which was contractor based. I wasn't wealthy (at least not by the standards set in the UK if you speak to a financial advisor) and £60k was a large amount of money for me to spend (a very large amount). But all things going well with life, you earn it, you spend it, we decided we wanted to do some of that spending earlier in life whilst we could enjoy it.

Since then... I have had heart ops, a blood clot on the lung, my partner has developed ME/chronic fatigue syndrome... COVID19 has engulfed the world. Needless to say we are glad, thankful and lucky we did what we did when we did!

It took a while to plan, not just the trip stuff but finishing a job, packing up a house, signing cars off the road, cancelling bills etc.

We got a round the world flight ticket, we had to commit to the first six month flight times then half way through commit to the rest. It was possible to change for a fee. But we found the flights gave us a schedule to work around.

Some parts we planned extensively (you can't go to Tibet without being on a tour the whole time you are there, Machu Picchu books up months in advance, etc) other parts (Vietnam, Cambodia, Laos, Thailand) there is somewhat of an established back packer route you can follow and just make sure you get through in time for the next flight.

By far the least safe place was South America, we met many travellers there who had been mugged, beaten up, etc. It was our last destination and we were not very adventurous as we were tired and also just wanted to get to the end without an incident.

Other than that, we generally felt safe, there were one off isolated incidents (drunk Russian man on train trying to make advances on my partner when he thought I was asleep) which were uncomfortable, or going to a train station in Jaipur at 3 in the morning and waiting for a train, with lots of people loitering around and bothering us, and no real security or staff to reassure us, but these were exceptions rather than the norm.

We typically went to places which had a reasonable number of travellers, so it didn't feel too crazy in that sense.

My partner and I took a year out for all of 2018 and travelled for 365 days, aged 34. We went to 21 countries during that time, the route:

UK India Hong Kong Vietnam Cambodia Laos Thailand Russia Mongolia China Tibet Japan Malaysia Indonesia Australia New Zealand Fiji Hawaii North America Chile Bolivia Peru Colombia Brazil

We saw many wonders of the world (from various lists) including Taj Mahal, Angkor Wot, Great Barrier Reef, Machu Picchu and Christ the Redeemer.

We drove coast to coast in the US (LA to New York via the South) over a month.

We took the Trans-Siberian Express train across Russia to Beijing (St Petersburg, Moscow, Kazaan, Yekaterinburg, Novosibirsk, Irkutsk, Lake Baikal, Ulaanbaatar, deeper into Mongolia and stayed in a Gerr and Beijing).

We also looped around China by train including going to Tibet via Xinning. Tibet is like nowhere else we have been in the world.

We spent a couple of weeks driving around New Zealand South Island in a campervan.

We did the classic backpacker route around South East Asia, traveling overnight on sleeper buses, visiting the tourist destinations, site seeing, going on a booze cruise party island in the middle of a site of natural beauty (Castaways), visiting temples, full moon party. All in all a bit of everything. We were at the absolute age limit of some activities and accomodation, where although they were willing to show some flexibility, you wouldn't want to be much older as the majority of people were about 20. At times we felt old and past it, but we were happy we went ahead and did it.

Whilst a lot of the trip we just planned and booked ourselves, small parts, like Australia, we went on an organised trip. It wasn't one where we follow a tour leader, instead we were given vouchers for accomodation and activities and transport that went from Cairns down to Melbourne and followed it ourselves. It included dolphin feeding, scuba diving at the great barrier reef, driving around Fraser Island on 4x4s and staying a couple of nights, going on a boat tour of the Whitsundays and seeing White Haven beach with the softest sand I have experienced.

We could have done a fraction of the amount of stuff we did, and seen more or each place. We could have recouperated more rather than end up exhausted. But it was one hell of a trip.

I worried about finding work when it was over, but had several job offers before I returned so that turned out to be a false worry!

This doesn't reflect my experience from the UK. In the UK a club to people I know is thought of roughly as:

- Late (22:00 - 03:00 probably been core hours)

- Music/dancing being the primary activity

- A small amount of seating, either VIP tables, or some small area or bit near the dance floor

- Alcohol (and perhaps drugs) being consumed quite liberally

- A lot of the clientele looking for a short term partner

The dress side of it just varies, there are places with little to no dress code, places that require shirt and shoes and others inbetween, but I wouldn't specifically say the dress code leads to fundamentally different places, except, the more relaxed dress code typically means more relaxed, diverse people, where as fancy dress code can be a bit more mainstream/think-they-are-something-special.

Places you sit down at tables and drink are typically pubs or bars. These days the two are pretty similar, at a push the more traditional feeling places are more likely to being pubs.

When I was younger I went to the above type establishments not just in the UK but in pretty much every country in the EU and something I found in lots of the EU is something I call "europop" nightclubs, which is a bit harder to explain, but it is venues which are really laid back, everyone just wants to have fun (no aggressive behaviour, male dominance/competition) and plays a whole host of music that has never come to the UK, but everyone over there knows. All of my best club experiences have been these type of places - it's where a 30 year old rock influenced person can be dancing away next to a mainstream 18 year old student and they can chat without barriers.

I do see an increasing amount of younger people that don't really drink and fuel their social interactions from Tinder and other social media, so I have wondered a few times if clubs will fade further out over the years.

Just a little FWIW, I am with Hyperoptic in the UK (pretty common if you live in an apartment in a big city centre). They provide nice fast, cheap, fibre broadband (1Gbit/sec in both directions). I started allowing remote connections on my Plex (media server) but couldn't get it to work, which is puzzling as I have been setting up put forwarding for 25 years, so thought I had run out of unsolved mysteries. Then I read about CGNAT. Then I found out Hyperoptic uses CGNAT. I felt like I had been swindled, an internet connection which ample bandwidth for hosting services with no way to have any incoming ports (as no matter what portforwarding I set up on my router, the ISPs CGNAT router doesn't let me set any portforwarding up as it is out of my control).

I spoke to Hyperoptic, they said I could have a fixed (non CGNAT) IP for five months for free and then £5 per month thereafter. After five months I noticed they had started charging me £1.25 per month. I am not sure if that will increase to £5 at some point, but either way, I am happy to pay to have a "proper" internet connection.

I share this as perhaps others will be in similar situations but not realize some ISPs will let you escape the CGNAT. They switched me after a five minute chat and within 2 hours (considerably less but they said up to 2 hours) I restarted my router and I was good to go.

This feels like a fun lightweight version of one of our products, vTime XR https://vtime.net/vtimexr which lets you chat with people both in VR and on mobile. It is amazing how much better chat is when you can face people and speak to them. When you throw in VR it gets pretty exciting too. Thanks for sharing.

1 in 1,000 people in the UK have died after contracting COVID (this number is rising).

2 people out of thousands vaccinated yesterday had an allergic reaction that they recovered from (both people carry EpiPens and have a history of allergic reactions).

Monitoring systems mean we know about this, so bottom line is everything is going well so far. We will obviously want to continue to monitor.

I and a huge amount of other people are living in a flat which currently has a value of £0 and am currently waiting to find out how much remediation works are going to cost to make the building I live in safe. As it is deemed unsafe by retrospective government fire and safety requirements, it is impossible to get a new mortgage for and therefore impossible to sell. The remediation costs are likely to be in the 10's of thousands of pounds.

The building may have been built to meet the requirements at the time (12 years ago) and then again it may not have. The guidelines have also obviously changed since Grenfell. But as it stands right now, all costs are to be passed onto the leaseholder i.e. the person who owns and lives in the flat i.e me. I moved in one year ago, had all the survey's done, used a solicitor and followed all procedure. Other people are in even worse positions, if they can't afford a bill of £50,000 their only option maybe bankruptcy, if they are in various legal professions or an accountant this means automatically losing their license to practice. Other people who have used the governments partial ownership scheme, where you buy 25% of a property and then rent (paying 25% less rent per month) are being asked to pay 100% of the remediation costs. For a lot of people the costs are more than the 25% stake in the property they own.

Some property developers followed the guidelines at the time so say it isn't their fault. The government says it followed the standards at the time so it isn't their fault. The building inspectors which failed to properly inspect properties (when there were actual issues outside of what has been changed retrospectively) seem to have immunity against legal action. The cladding companies who made unsafe cladding are trying to weasel their way out of responsibility by saying it is safe in the right circumstances. It feels like there are a few slices of blame to dish out. But one party who has had NO involvement in any of this is the people living in the flats.

The most sensible option I have heard suggested so far is that the government pays to clean up this entire scandal, and then puts a levy on property developers making flats so they get a percentage back on each new development to slowly recoup the money. But instead of that, the government is making various noises about wanting to protect leaseholders whilst simultaneously not doing anything concrete, even though as I write this people are already filing bankruptcy, giving up their flat which has all the money they have ever saved in, and on top of that, the remediation work in subject to VAT so the government brings in tax for all work done to fix up this mess. You can track huge sums (millions of pounds) being donated/pumped into the conservative party by property developers, and of course members of the conservative party also have shares or other stakes in property development companies.

It is a scandal of the highest order.

Hum to Search Song 6 years ago

Colour me amazed! I saw a video of some buskers which someone shared a week ago and the tune I know but couldn't remember where it was from, it is a waltz and I thought maybe Swan Lake or Nutcracker but after listening to the soundtracks it clearly was not. At some point I was going to work out the melody on the piano (very basic strap line) and use that to search (there are a few sites which offer this and I have had luck with it in the past). But I just tried humming to Google, I have a sore throat after a minor op, have not long got up, and can't hum or hold a tune to save my life, but low and behold it offered up 3 results and it was the second one.

The Second Waltz, Johann Strauss.

Okay, a very famous piece of music, and a very recognizable melody, but I just thought my warble was so far off that most humans wouldn't be able to tell me what it was!

I remember, when starting university, with no real programming knowledge, making a little game in my spare time (a clone of Pang if you know it) but it was before I knew what a linked list is. I implemented things like the balls which bounce around the level in an array, and just gave that array a max size. I was very unsatisfied by this, and then later finding out about linked lists was an ah-hah moment, very satisfying.

Next project was making a "Countdown" game, where you are given 9 pseudo random letters and have to make the longest word you can. I found a dictionary as a text file, so could see if the word you entered existed. The game was on Gameboy Advance, so not a huge amount of space or very fast CPU. As you can imagine, walking the entire dictionary file from start to end looking for a word was far too slow. So there was another ah-hah moment when binary search was introduced.

Next I worked on a rendering engine for this device called GP32, you basically got a pointer to the screen buffer and could put what you liked in it, so I learned how to write polygon fill routines, back face call, etc but didn't know what perspective projection was or how to find out about it. I finally found a book, Game Programmers Black Book or something like that, which explained perspective projection, at least to some extent, another ah-hah moment (previously I was dividing my XY by Z as I knew I wanted things smaller in the distance but this doesn't give a nice result by itself).

These are just very early examples when I first started programming, when information was harder to find, and when a lot of games development involved DIY, if you want a polygon you need to pixel fill a polygon! Even when PS2 came out you still had to write ASM render programs to take an array of vertices and transform them, their UVs, etc and send them to the Graphics Interface.

But I haven't found later tech developments have stopped me finding and needing to use other algorithms and structures. Just last week I had to diagnose a crash which resulted with the target device and debugger showing a nonsensical callstack, so I enabled the profile options in GCC/Clang so I had an epilogue / prologue for every function that is called, so I could store my own call graph history, and then, on crash, display it nicely, with indentation etc. This allowed me to see what happened just before the crash (turned out to be a system UTF16 conversation routine stomping over a pointers boundaries as the NULL termination of the string was incorrectly done as if the string was a normal char*, effectively NULL terminating half of a UTF16 pair, which wasn't treated as a terminate, so the actual bug was bad string termination done by the off the shelf engine we use). As the profile code ran twice for every single function that was run, it had to be pretty efficient, using appropriate data structures, etc.

So I guess the point of this post is to say I believe having a good knowledge of algorithms and data structures always seems beneficial to me. The extent which some companies push them is too much for me, but I don't think this should lead to us thinking it is all pointless. There is a nice balance out there.

I have an Early 2011 MBP which I stopped using precisely because it couldn't get Mojave and therefore couldn't run the latest Xcode and therefore couldn't build for iOS 13. When I searched it sounded like any hacked upgrades would leave the graphics in a pretty poor state and it sounded like it just wouldn't be worth it. So I am curious on your results?