Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "substitution"
-
I was unemployed and had to sent out 10 or so job applications per month to e eligible to receive the money substitution for unemployment...
Anyways, not many jobs fit my experience, so I was sending out to those with higher/different requirements aswel.. That day I was meeting my sister and she was already waiting for me, so I quickly sent out a totally unpersonalised application for a job I wasn't qualified for. Next day I got back response email with a self grading questionaire I didn't really understood, all about MS technologies I never worked with..which means I didn't know how to grade myself..I decided to ask around people to try to help me grade myself, but then I totally forgot about that in the next days and never replied to that email.
Anyways, week later I got email for job interview from a sister company (found that out later, snooping through linkedin). I was surprised someone requested a meeting with me, especially without the agenda (at that time I was not aware it was a job interview).. Anyways I went there, found out the guy interviewing me thought they lost my questionaire. I explined the situation and he just decided to ask me around to see what I know. So we talked about my past experience and the guy who was doing the interview explained what is what & and explained what I did before and together we figured out what I know and what my experiences are... After we were done, he said that everything else, the payment and other stuff about the job position I should discuss with the director. Not to ask questions, but negotiate.. O.o And just like that I got the job, because they liked my CV & attitude (I like to learn new stuff) and they thought I'd fit in perfectly.
I'm still working there, it's been 4 years now, I think.. loved it since the day one.. Got 'promoted' to another project, crappy old code noone wants/dares to touch but I love it! The guys think I am weird cuz I like to solve/fix things and make them better, and previous employees who worked on that project have all lost their shit and quit. They are all wondering how I can handle this, but little do they know about devrant & my love for the crazy!!2 -
This is a story of how I did a hard thing in bash:
I need to extract all files with extension .nco from a disk. I don't want to use the GUI (which only works on windows). And I don't want to install any new programs. NCO files are basically like zip files.
Problem 1: The file headers (or something) is broken and 7zip (7z) can only extract it if has .zip extension
Problem 2: find command gives me relative to the disk path and starts with . (a dot)
Solution: Use sed to delete dot. Use sed to convert to full path. Save to file. Load lines from file and for each one, cp to ~/Desktop/file.zip then && 7z e ~/Desktop/file.zip -oOutputDir (Extract file to OutputDir).
Problem 3: Most filenames contain a whitespace. cp doesn't work when given the path wrapped in quotes.
Patch: Use bash parameter substitution to change whitespace to \whitespace.
(Note: I found it easier to apply sed one after another than to put it all in one command)
Why the fuck would anyone compress 345 images into their own archive used by an uncommon windows-only paid back-up tool?
Little me (12 years old) knowing nothing about compression or backup or common software decided to use the already installed shitty program.
This is a big deal for me because it's really the first time I string so many cool commands to achieve desired results in bash (been using Ubuntu for half a year now). Funny thing is the images uncompressed are 4.7GB and the raw files are about 1.4GB so I would have been better off not doing anything at all.
Full command:
find -type f -name "*.nco" |
sed 's/\(^./\)/\1/' |
sed 's/.*/\/media\/mitiko\/2011-2014_1&/' > unescaped-paths.txt
cat unescaped-paths.txt | while read line; do echo "${line// /\\ }" >> escaped-paths.txt; done
rm unescaped-paths.txt
cat escaped-paths.txt | while read line; do (echo "$line" | grep -Eq .*[^db].nco) && echo "$line" >> paths.txt; done
rm escaped-paths.txt
cat paths.txt | while read line; do cp $line ~/Desktop/file.zip && 7z e ~/Desktop/file.zip -oImages >/dev/null; done3 -
Every website we craft at work has some email substitution logic so that addresses you see on the site don't actually exist in the HTML source like that (you wouldn't find them in a format like "foo@example.com").
Instead the @ and the period right before the TLD get replaced with something else (to prevent (dumb) spam bots from using that address and blast it with junk).
Some people replaced them with images in the past (ew), replaced the @ with "(at)" or other stuff.
I made it a habit to render the @ and . by replacing them with span tags which then get a ::before in CSS that contains "content: '@';", so that the @ is visible but is not actually inside the HTML source code.
The classes for these spans then have a random name (persistent for that website though). The first one was called "move-along-nothing-to-see-here", but then I started naming them after Star Wars quotes.
One website's @ class is called "that-s-no-moon" (Obi Wan), others are called "i-have-a-bad-feeling-about-this" (Han Solo), "powerful-you-have-become-the-dark-side-I-sense-in-you." (Yoda) and "these-are-not-the-droids-you-are-looking-for" (Obi Wan).12 -
This is a sad story of bad recruitment in my school.
One day I had my computer class in school and my teacher was on leave so the substitution department sent another teacher to our class.
I have 3 computer teachers in my institution, let us assume their names for this rant as A, B and C.
A - The most learned teacher who has a lot of experience and also writes books. This teacher is the head of the department and wants students to explore coding.
B - A teacher who sticks to books and writes books on Excel and Powerpoint for small children.
C - The youngest teacher who has almost no experience at all.
What happened was that during the substitution, teacher C was sitting and doing her own work. I thought she might know java and other fundamentals of computers. One of my friends asked her about some bug in his program. She went to his seat and said that teacher A would come and help you out. To this, the student said ok.
I thought that the teacher had something fishy going on.
A few months later teacher B and A were talking about some coding competition and I was alone in the lab cause I am the only one in 11th with computer science.
The problem here was that C came to the room and quietly asked what is an object and class in java. I was shocked! I mean how could that happen, she is supposed to know everything in the comp sci syllabus. This was a disaster, teacher A was explaining to her about classes and objects. It was clear to me that she didn't know anything about programming in Java.
This is the fault of our school.
My school wants a good rank in the lists and for that they cut down the budget of teachers and remove old, experienced teachers for cheap, newer teachers.
This was shocking as a person who doesn't know much about something can't answer the doubts of children, this is a wrong way of teaching.
Hope you have a good day :)7 -
God....
Bash and substitution patterns is character diarrhea.
And said Bash "script" consists of multiple shitton files with sources and Environment variables and other stuff that makes me wanna poke my eyes out and cram it into my arse.
Still shitty, but more tolerable.
I will have an clusterfuck of nightmares I guess.
All these # will gangup with the ~ and then the ? will start an knife attack to rip out their intestines. But all fails as the ! shred everything to bits by blasting it with anti tank sniper munition.
*dizzy*10 -
Mac text substitution is coming to Chrome 77!
https://bugs.chromium.org/p/...
...and it's a TERRIBLE BLOODY IDEA. Any Chrome Mac users visiting any sites that display code will likely be shown the substituted crap, unless they've picked up on it and modified their site in time.
Seriously, take these cutsie "oohhhh, I want my ellipsis to display as a *proper* ellipsis character" mindsets and shove them where the sun don't shine. By all means provide the functionality as opt-in via a CSS declaration or whatever, but don't just assume your love of bloody "smart quotes" trumps everyone else's ability to see the *actual content* on the site.
Grumbly grumble old fart grumble.2 -
I had the idea that part of the problem of NN and ML research is we all use the same standard loss and nonlinear functions. In theory most NN architectures are universal aproximators. But theres a big gap between symbolic and numeric computation.
But some of our bigger leaps in improvement weren't just from new architectures, but entire new approaches to how data is transformed, and how we calculate loss, for example KL divergence.
And it occured to me all we really need is training/test/validation data and with the right approach we can let the system discover the architecture (been done before), but also the nonlinear and loss functions itself, and see what pops out the other side as a result.
If a network can instrument its own code as it were, maybe it'd find new and useful nonlinear functions and losses. Networks wouldn't just specificy a conv layer here, or a maxpool there, but derive implementations of these all on their own.
More importantly with a little pruning, we could even use successful examples for bootstrapping smaller more efficient algorithms, all within the graph itself, and use genetic algorithms to mix and match nodes at training time to discover what works or doesn't, or do training, testing, and validation in batches, to anneal a network in the correct direction.
By generating variations of successful nodes and graphs, and using substitution, we can use comparison to minimize error (for some measure of error over accuracy and precision), and select the best graph variations, without strictly having to do much point mutation within any given node, minimizing deleterious effects, sort of like how gene expression leads to unexpected but fitness-improving results for an entire organism, while point-mutations typically cause disease.
It might seem like this wouldn't work out the gate, just on the basis of intuition, but I think the benefit of working through node substitutions or entire subgraph substitution, is that we can check test/validation loss before training is even complete.
If we train a network to specify a known loss, we can even have that evaluate the networks themselves, and run variations on our network loss node to find better losses during training time, and at some point let nodes refer to these same loss calculation graphs, within themselves, switching between them dynamically..via variation and substitution.
I could even invision probabilistic lists of jump addresses, or mappings of value ranges to jump addresses, or having await() style opcodes on some nodes that upon being encountered, queue-up ticks from upstream nodes whose calculations the await()ed node relies on, to do things like emergent convolution.
I've written all the classes and started on the interpreter itself, just a few things that need fleshed out now.
Heres my shitty little partial sketch of the opcodes and ideas.
https://pastebin.com/5yDTaApS
I think I'll teach it to do convolution, color recognition, maybe try mnist, or teach it step by step how to do sequence masking and prediction, dunno yet.6 -
Why are most projects only fun at the beginning? I feel like there should be a "first half" and a "second half" during development.
So if I have worked the whole of first half someone else should work the other half with full bar and zeal just like a football match because honestly most times I feel like I'm gonna die towards the end of the project hoping for another developer to come on as a substitution.
However, in this case instead of going to seat on the bench after being substituted, I am willing to play another match immediately.4 -
Today, I have installed/uninstalled a combination of [windows 7, arch linux, dual-boot] a total of 9 times...
I wouldn't be surprised if my 120G SSD fails next week
It all started when I had to whip up a GUI-wrapped youtube-dl based program for a windows machine.
Thinking a handy GUI python library will get it done in no time, I started right away with the Kivy quick-start page in front of me.
Everything seemed to be going fine, until I decided it would be "wise" to first check if I can run Kivy on said windows machine.
Here I spent what felt like a day (5 hours) trying to install core pip modules for kivy.. only before realizing my innocent cygwin64 setup was the reason everything was failing, and that sys.platform was NOT set to "win32" (a requirement later discovered when unpacking .whl files)
"Okay.. you know what? Fuck........ This."
In a haze of frustration, I decided it was my fault for ever deciding to do Python on windows, and that "none of this would've happened if I were installing pip modules on a Linux terminal"...
I then had the "brilliant" idea of "Why don't I just use Linux, and make windows a virtual machine within, for testing."
And so I spent the next hour getting everything set up correctly for me get back to programming.... And so I did.
But uh... you're doing GUI stuff, right? -> Yeah...
And you uh.. Kivy uses OpenGL on windows, doesn't it? -> Yeah..?
OpenGL... 2.
-> Fuck.
That's when I realized my "brilliant" idea, was actually a really bad prank. Turns out.. I needed a native windows environment with up-to-date non-virtual graphics drivers that supported at least OpenGL2 for Kivy GUI programs!
Something I already had from square 1.
And at this point, it hurts to even sigh knowing I wasted hours just... making... poor decisions, my very first one being cygwin64 as a substitution for windows cmd.
But persistent as any programmer should be in order to succeed, I dragged my sorry ass back to the computer to reinstall windows on the actual hardware... again.
While the windows installer was busy jacking off all over my precious gigabytes (why does it need that much spaaace for a base install??? fuck.). I had "yet another brilliant idea" YABI™
Why not just do a dual-boot? That way, you have the best of both worlds, you do python stuff in Linux, and when it's time to build and test on the target OS, you have a native windows environment!
This synthetic harmony sounded amazing to the desperate, exhausted, shell of a man that I had become after such a back-breaking experience with cygwin
Now that my windows platter with a side of linux was all set-up and ready-to-go, I once again booted up windows to test if Kivy even worked.
And... It did!
And just as I began raising my victory flags, I suddenly realized there was one more thing I had to do, something trivial, should take me "no time" to do, being in a native windows environment and all.................... -.- (sigh)
I had to make sure it compiles to a traditional exe...
Not a biggy, right? Just find one of those py2exe—sounding modules or something, and surprisingly enough, there was indeed a py2exe—sounding module, conveniently named... py2exe.
Not a second thought given, I thought surely this was a good enough way of doing it, just gonna look up the py2exe guide and...
-> 3 hours later + 1 extra coffee
What do you meeeeean "module not found"? Do I need to install more dependencies? Why doesn't it say so in the DAMN guide? Wait I don't? Why are you showing me that error message then????
-------------------------------
No. I'm not doing this.
I shut off my computer and took a long... long.. break.
Only to return sometime the next day and end up making no progress, beating my SSD with more OS installs (sometimes with no obvious reason to do so).
Wondering whether I should give up Kivy itself as it didn't seem compatible with py2exe.. I discovered pyInstaller, which seemed to be the way Kivy wants exe's to be made on windows..
Awesome! I should've looked up how Kivy developers make exe's instead of jumping straight into py2exe land, (I guess "py2exe" just sounded more effective to me then)
More hours pass, and you'd think I'd have eliminated all of my build environment problems by now... but oh, how wrong you'd be...
pyInstaller was failing, and half the solutions I found online were to download some windows update KB32946..whatever...
The other half telling me to downgrade from Python 3.8.1 to Python 3.8.0000.009 (exaggeration! But you get the point)
At the end of all that mess, I decided it wasn't worth some of my lifespan, and that maybe.. just maybe.. it would've been better to create WINDOWS GUI with the mother fuc*ing WINDOWS API.
Alright, step 1: Get Visual Studio..
Step 2: kys
Step 3: kys again.6 -
Okay so I’ve been brought in on a 12 month contract as an external replacement integration architect, alongside a large IT consulting firm. Turns out, they don’t need an integration architect. So I fill my time coming up with useful tools around the project that deal with all the missing parts in their MVP: like monitoring tools, data mocking tools, you get the idea. Essentially doodling.
Client has woken up to fact that they’ve overspent by X million, employing 30+‘developers’, 20+ ‘testers’, n+ ‘managers’ on a ‘low-code’ project … result: project shuts 4 months early.
Q: Essentially client wants remaining four months work done in two weeks. Is there a German word for laughing, crying, and banging the forehead on the desk at the same time?
Supplementary: how cross will client be when they realise project can indeed be done, and that consultancy have been emperor’s-new-clothing them for most of the last two years?
(Feel free to perform substitution on quoted terms at your leisure)2 -
1/2 dev and a fair warning: do not go into the comments.
You're going anyway? Good.
I began trying to figure out how to use stable diffusion out of boredom. Couldn't do shit at first, but after messing around for a few days I'm starting to get the hang of it.
Writing long prompts gets tiresome, though. Think I can build myself a tool to help with this. Nothing fancy. A local database to hold trees of tokens, associate each tree to an ID, like say <class 'path'> or some such. Essentially, you use this to save a description of any size.
The rest is textual substitution, which is trivial in devil-speak. Off the top of my head:
my $RE=qr{\< (?<class> [^\s]+) \s+ ' (?<path>) [^'] '\>}x;
And then? match |> fetch(validate) |> replace, recurse. Say:
while ($in =~ $RE) {
my $tree=db->fetch $+{class},$+{path};
$in=~ s[$RE][$tree];
};
Is that it? As far the substitution goes, then yeah, more or less. We have to check that a tree's definition does not recurse for this to work though, but I would do that __before__ dumping the tree to disk, not after.
There is most likely an upper limit to how much abstraction can be achieved this way, one can only get so specific before the algorithm starts tripping balls I reckon, the point here is just reaching that limit sooner.
So pasting lists of tokens, in a nutshell. Not a novel idea. I'd just be making it easier for myself. I'd rather reference things by name, and I'd rather not define what a name means more than once. So if I've already detailed what a Nazgul is, for instance, then I'd like to reuse it. Copy, paste, good times.
Do promise to slay me in combat should you ever catch me using the term "prompt engineering" unironically, what a stupid fucking joke.
Anyway, the other half, so !dev and I repeat the warning, just out of courtesy. I don't think it needs to be here, as this is all fairly mild imagery, but just in case.
I felt disappointed that a cursed image would scare me when I've seen far worse shit. So I began experimenting, seeing if I could replicate the result. No luck yet, but I think we're getting somewhere.
Our mission is clearly the bronwning of pants, that much is clear. But how do we come to understand fear? I don't know. "Scaring" seems fairly subjective.
But I fear what I know to be real,
And I believe my own two eyes.11 -
MICROSERVICES ARE NOT A SUBSTITUTION FOR GOOD DEV PRACTICES, IF YOU WERE A WERECODER BEFORE MICROSERVICES, A MIGRATION WILL NOT TEACH YOU/YOUR TEAM HOW TO CODE.4
-
I use the ICU format often for translation because it's simple enough and supported on many platforms. It's something of a standard so I can use the same translation string format and similar library functions everywhere.
ICU is like a really simple templating language, somewhere between printf and something like smarty or twig simplified and specifically intended for internationalisation.
I updated a library providing ICU compatible parsing and formatting for one of the platforms I'm using and find tests break. I assume that only thing to change is the API. ICU very rarely changes and if it did it would be unexpected for it to break the syntax in a major way without big news of a new syntax.
The main contributor of the library has changed since some time last year. Someone else picked up the project from previous contributors.
Though the library is heavily advertised as using ICU it has now switched to using a custom extended format that's not fully compatible and that is being driven by use case demand rather than standardisation.
Seems like a nice chap but has also decided for a major paradigm shift for the library.
The ICU format only parses ICU templates for string substitution and formatting. The new format tries to parse anything that looks XML like as well but with much more strict rules only supporting a tiny subset of XML and failing to preserve what would otherwise be string literals.
Has anyone else seen this happen after the handover of an opensource library where the paradigm shifts?3 -
Exploring dedekinds and kronecker products (script at - https://pastebin.com/dDuT3dTp)
and the thing I immediately notice, if you output the matrix is that it is a lower triangular matrix. I don't know a lot about the kronecker or matrices in general, but if dedekinds can be generated in this manner, shouldn't some standard approaches like back substitution or forward substitution be applicable here or am I off in left field on this?6 -
Unit testing with NSubstitute and Autofac
For the most part, I find it a lot simpler than SimpleInject (hmm) and Moq, which I have used previously.
But there are still some of those 'Oh, for fucks sake!'-gotchas.
I was trying to test a class today where I wanted to substitute all other methods in the class than the one I wanted to test == an actual unit test.
I had previously found out how to do this:
1. Make sure the methods that should be substituted are internal to allow substitution.
2. Substitute class with Substitute.ForPartsOf<T>(args)
3. Set up methods that should not be called with instance.When(a => a.Method()).DoNotCallBase()
This way, you can unit test a class properly and only call the method that you want to test, and also control the return values of the other methods if needed.
So as I said, I have used this before to great effect. But today I just could NOT get it to work! I checked and rechecked everything but the test code kept calling the implementations of the substituted methods!
I even called over another dev for help, but he couldn't see the problem either.
Aargh!
I scoured the internet, but everyone just told me what I already knew: follow the 3 steps, and all is well. Not so!
I ALMOST considered doing the test improperly, as in, increasing the scope beyond that of the method I wanted to test.
But then it hit me... My project was missing this line in AssemblyInfo.cs:
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
I always add a line to make internals visible to the test project, but I had forgotten that NSubstitute needs this line as well to work properly.
Sometimes when a test fails it will tell you that you are missing this line. And sometimes it just doesn't work.
Maybe I will remember this in the future now. Maybe 😅 -
I will leave in September this job location, but what's weird is that I've already (yesterday, a causality) shacked the hand to the next probable guy that going to continue on my work.
I do have planned the change of location by the same company, btw.
Is it normal to see this happening so early? (More than 4 months) -
Orchid lesson #many:
Church tuples exist only to demonstrate how general substitution is. Just like Church numerals, they aren't meant to be used for real computation and cause a lot of problems. Few type systems and fewer optimizers can deal with them, they're a pain to pass through FFI boundaries, and they're much slower in an interpreted context than a native smart array. And in a lazy language the tuple is almost always lighter than the code that generates it, so you want to generate the tuple eagerly and thunk the actual elements, if thunk you must.
I'll go write a vector based tuple and end this madness tomorrow. New version soon, probably.
With dynamic dispatch.7 -
How bash does not support redirecting stderr to /dev/null when using read redirection inside command substitution is F*CKING ANNOYING.
x=$(</foo/non_exitence_file.txt 2>/dev/null)
Why do people still use this shit of a shell?2 -
Starting Out In Web Development (again)
The Question
I am looking for some suggestions on tools or frameworks to look into for a hobby project I wanted to try. I have always felt that _time_ is quite interesting so I was going to knock something up to present the current time in a lot of formats (All the ISOs I can find, GPS Time, Week Numbers, Mian Calendars, Metric Time, etc).
My Background
It has been a while since I did anything much with website related bits. Long ago I wrote HTML (4 or XHTML I think) out but hand for simple things. I added a little JavaScript to do a rollover image substitution. At some point I also did some JavaServerPages (JSP).
In the non-web world;
* I am quite good at C & C+
* I am OK with Go, Python, Ruby, BASH
* I can cobble together JavaScript, Java, JSP and a bunch of other things but I will be a bit slow and doing a lot of "online research" to aid me.
-----
Any suggestions are very welcome. Also if you know of similar existing sites I would be interested to see how others have chosen to present things.