Nordic Nrf52840 ports - port

I know this is a likely a dumb question but if you can set Port0.5
with NRF_GPIO->OUTSET = 1UL << 5;
what is the equivalent statement for setting Port1.5?
Thanks.
Bob

OK - Figured it out - I think. In the 52840 there are two ports. Other
devices only had one. I saw something where NRF_GPIO was renamed NRF_P0.
I tried NRF_P1->OUTSET = 1UL << 5; and it compiled successfuly.

Related

Differentiating Mode 2 Form 1 from Mode 2 Form 2 on XA CD-ROMs?

I'm developing a library for reading CD-ROMs and the ISO9660 file system.
Long story short, pretty much everything is working except for one thing I'm having a hard time figuring out how it's done:
Where does XA standard defines differentiation among Mode 2 Form 1 from Mode 2 Form 2?
Currently, I am using the following pseudo-code to differentiate between both forms; albeit it's a naive heuristic, it does work but well, it's far from ideal:
var buffer = ... // this is a raw sector of 2352 bytes
var m2F1 = ISector.Cast<SectorMode2Form1>(buffer);
var edc1 = EdcHelper.ComputeBlock(0, buffer, 16, 2056);
var edc2 = BitConverter.ToUInt32(m2F1.Edc, 0);
var isM2F1 = edc1 == edc2;
if (isM2F1) return CdRomSectorMode.Mode2Form1;
// NOTE we cannot reliably check EDC of M2F2 since it's optional
var isForm2 =
m2F1.SubHeaderCopy1.SubMode.HasFlag(SectorMode2Form1SubHeaderSubMode.Form2) &&
m2F1.SubHeaderCopy2.SubMode.HasFlag(SectorMode2Form1SubHeaderSubMode.Form2);
if (isForm2) return CdRomSectorMode.Mode2Form2;
return CdRomSectorMode.Mode2Formless;
If you look at some software like IsoBuster, it appears to be a track-level property, however, I'm failing to understand where the value would be read from within the track.
I'm actually doing something similar in typescript for my ps1 mod tools. It seems like you actually probably have it correct here, since I'm going to assume your HasFlag check is checking position bit position 6 of the subheader. If that flag is set, you are in form 2.
So what you probably want something like:
const sectorBytes = new Uint8Arrray(buffer);
if (sectorBytes[0x012] & 0x20) === 0x20) {
return CdRomSectorMode.Mode2Form2;
} else {
return CdRomSectorMode.Mode2Form1;
}
You could of course use the flag code you already have, but that would require you to use one of the types first to get that. This just keeps it generic bytes and checks the flag, then returns the relevant mode.

Link encryption?

I have been stuck on a problem for a few hours. Nothing online has helped and I'm losing the will to live right now.
The site loads up a question with no hints and asks you to find a secret code.
Here's the brief explanation of it:
'Well done on making it to the secret bonus challenge! Our agents have been struggling to deal with a hacker obsessed with clocks and timing. He set up an elaborate collection of pages with content that changes based on a timer. We've replicated it below, can you figure out how to get the secret code?'
There are many links inside this challenge and when they are clicked it opens to a new website and has pseudo strings in there, I don't see much pattern. Links below:
https://assess.joincyberdiscovery.com/challenge-files/clock-pt1?verify=BY%2F8lhw%2BtbBgvOMDiHeB5A%3D%3D
https://assess.joincyberdiscovery.com/challenge-files/clock-pt2?verify=BY%2F8lhw%2BtbBgvOMDiHeB5A%3D%3D
https://assess.joincyberdiscovery.com/challenge-files/clock-pt3?
verify=BY%2F8lhw%2BtbBgvOMDiHeB5A%3D%3D
https://assess.joincyberdiscovery.com/challenge-files/clock-pt4?
verify=BY%2F8lhw%2BtbBgvOMDiHeB5A%3D%3D
https://assess.joincyberdiscovery.com/challenge-files/clock-pt5?verify=BY%2F8lhw%2BtbBgvOMDiHeB5A%3D%3D
(If it doesn't allow you to go on) then what it has is just a tag and no element with what it seems a three character code which always ends in 'a' for example 'Aja' and makes a new one every 10 seconds (which is not re-generated client side.)
Anyone have any suggestions to whether or not the link is a hint of encryption or not? I've decrypted it once and it came up with:
'https://assess.joincyberdiscovery.com/challenge-files/clock-pt5?verify=BY/8lhw tbBgvOMDiHeB5A==' which isn't much help.
Anyways, anyone have any suggestions?
Thanks :)
Its not impossible. I have the answer here:
import requests
page1 = "https://assess.joincyberdiscovery.com/challenge-files/clock-pt1?verify=wMHfxKSix2qSPJtLe6U98w%3D%3D"
page1_content = requests.get(page1)
page1txt = page1_content.text
page2 = "https://assess.joincyberdiscovery.com/challenge-files/clock-pt2?verify=wMHfxKSix2qSPJtLe6U98w%3D%3D"
page2_content = requests.get(page2)
page2txt = page2_content.text
page3 = "https://assess.joincyberdiscovery.com/challenge-files/clock-pt3?verify=wMHfxKSix2qSPJtLe6U98w%3D%3D"
page3_content = requests.get(page3)
page3txt = page3_content.text
page4 = "https://assess.joincyberdiscovery.com/challenge-files/clock-pt4?verify=wMHfxKSix2qSPJtLe6U98w%3D%3D"
page4_content = requests.get(page4)
page4txt = page4_content.text
page5 = "https://assess.joincyberdiscovery.com/challenge-files/clock-pt5?verify=wMHfxKSix2qSPJtLe6U98w%3D%3D"
page5_content = requests.get(page5)
page5txt = page5_content.text
code = (page1txt + page2txt + page3txt + page4txt + page5txt)
page6 = "https://assess.joincyberdiscovery.com/challenge-files/get-flag?verify=wMHfxKSix2qSPJtLe6U98w%3D%3D&string="+code
page6txt = requests.get(page6)
print (page6txt.text)
Replace all of the links with the links you are given

WoW API / Lua - Math.Random(#,#)

Always feel like I'm making something far more complicated than it has to be. I'm currently playing around with the WoW addon, Tongues, in hope of make a custom dialect filter - which is quite easy of course, very noob-friendly. At this point, there is one thing I want to accomplish-- something of which feels to have the implications far beyond this -- that is just novelty, but before I give up completely (lots of hours trying different things with no headway) I was hoping someone could come by, get a cheap laugh and perhaps help me fix this if they understand my point. And who knows, posting this new helpless questions might bump me up to being able to finally upvote!
Tongues.Affect["Drunk"] = {
["substitute"] = {
[1] = merge({
{ ["([%a]+)(%A*)$"] = "%1 ...hic!"},
Tongues.Affect["Slur"]["substitute"][1]
});
};
["frequency"] = 100;
};
What this does is simply add on the "...hic!" to sendchatmessage(); I believe it is. The frequency part seems completely broken and only the GUI slider in the game matters for that. What I was hoping to accomplish was to repurpose this and make the "...hic!" an actual randomized word. Since the mod itself handles the chance that it happens, I figured all that is needed left is to replace the string with a function=X. It's, of course, intensely way over my head, but despite checking the Lua of several mods, nothing feels like "it will fit."
The best I could come up with,
Tongues.Affect["TESTAFFECT"] = {
["substitute"] = {
[1] = merge({
{ ["([%a]+)(%A*)$"] = function(b)
local rand = Math.Random(1,2)
if (rand == 1) then
b = "test1"
return b
elseif (rand == 2) then
b = "test2"
return b
end
end
Leaves a gloriously useless message in the error mod BugSack - of course my attempt is wrong, but there's no way to know how!
I'm assuming this is enough information - as I said, very user friendly mod without any need to understand how it really works (Although I'd love to ready study it after this "project")
Anyone? Regardless, thank you for your time in simply even reading this far.
Update: Downvotes, okay! That's cool too. A little unpredictable, but sure. The error is as follows
15x Tongues\Core\dialects.lua:172: attempt to index field 'Affect' (a nil value)
Tongues\Core\dialects.lua:172: in main chunk
Locals:
175 in dialects.lua is
Tongues.Affect["Wordcut"]["substitute"][1],
Which has nothing to do with what I'm trying to accomplish, and works just fine.
Sorry that my question was an inconvenience. I asked to the best of my ability and the best of my ability to articulate the question proved to be less then stellar. The example codes I had provided were the only way I could articulate showing what I was trying to do.
I was misinterpreting the error frame and discovered that behind the useless stack that calls an error where there is, in fact, none, is a stack that calls the error in syntax at the time that broke it.
I'm sharing my results, regardless if the community finds this useless. I learned a tremendous amount from this personally, which is the only incentive in that I asked for help.
Tongues.Affect["TEST"] = {
["substitute"] = {
[1] = {
["([%a]+)"] = function(a)
return a
end;
["(%A*)$"] = function(a,b)
local rand = math.random(1,2)
if (rand == 1) then
b = "test1"
return b
end;
if (rand == 2) then
b = "test2"
return b
end;
end;
};
};
};
Hope it helps someone out there - as expected, I made it more complicated than it had to be. Simply "jiggling" the symbols is all that was needed.

web server memory leak issue

i'm create a dating website using symfony 1.4 (it's my first project using symfony). the problem is there server freezes if there is only 10 or less users online. i tryied optimizing my js, css, sprites using yslow i got grade A but still the problem is always there. that's why i think the way i build the application might be wrong so here is the website naijaconnexion.com i'm asking u for advices and things to do so i overcome this problem
If i wasn't clear enough just ask, if you want cpanel admin access i'll post it
i realy realy needs your help
for instance i have this code on my home page action does it seems ok or it needs to be optimized and how
$this->me = $this->getUser()->getGuardUser()->getPerson();
$this->cities = Doctrine_Core::getTable('City')->findByDql("zipcode=''");
$this->countries = Doctrine_Core::getTable('City')->findByDql("zipcode='10'");
$this->contacts = $this->me->getContacts();
$this->favorites = $this->me->getFavorites();
$this->matches = $this->me->getMatches();
$this->pager = new sfDoctrinePager('Conversation', sfConfig::get('app_home_conversations_per_page'));
$this->pager->setQuery($this->me->getConversationsQuery());
$this->pager->setPage($request->getParameter('page', 1));
$this->pager->init();
without HYDRATE_ARRAY
i can do this
if i use HYDRATE_ARRAY
will i be able to do stuff like $this->contacts[0]['username'];
help please
The problem is doctrine...
Try to fetch the needed values as array and set a limit!
How many objects are returned by the following queries:
$this->cities = Doctrine_Core::getTable('City')->findByDql("zipcode=''");
$this->countries = Doctrine_Core::getTable('City')->findByDql("zipcode='10'");
$this->contacts = $this->me->getContacts();
$this->favorites = $this->me->getFavorites();
$this->matches = $this->me->getMatches();
? Do not forget that they are object with references to other objects!
And yes, this will work $this->contacts[0]['username'];.
if you join the tables with the doctrine query, you can access related entities too - without executing additional queries.
$this->contacts = Doctrine_Core::getTable('Contact')
->createQuery('c')
->leftJoin('c.Users u')
->addWhere('...')
->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
$this->contacts[0]['Users'][0]['username']

What's the shortest way to generate a random IP address in Ruby?

Just like the title says, wanted for testing purposes.
You could use IPAddr
require 'ipaddr'
ipv4 = IPAddr.new(rand(2**32),Socket::AF_INET)
ipv6 = IPAddr.new(rand(2**128),Socket::AF_INET6)
If you want a truly random IP address, Array.new(4){rand(256)}.join('.') does it
I would suggest using Faker
https://github.com/stympy/faker#fakerinternet
Faker::Internet.ip_v4_address #=> "24.29.18.175"
ip = "%d.%d.%d.%d" % [rand(256), rand(256), rand(256), rand(256)]
I've used this before to generate a random ip then validate it with Resolv
ip = "#{rand(99)}.#{rand(100)}.#{rand(10)}.#{rand(255)}"
begin
if ip
host = Resolv.new.getname(ip)
puts "#{c} #{real_ip.length} #{ip} #{host}"
end
rescue Exception => e
puts "FAKE #{ip}"
end
I was going to tack on to Lass's comment with some code to get any safe RFC1918 address, but not enough reputation yet.
So, if we take the following math results:
10*2**24 = 167772160
172*2**24 + 16*2**16 = 2886729728
192*2**24 + 168*2**16 = 3232235520
and, stuff them into an array which is stuffed in the IPAddr.new method
IPAddr.new([167772160, 2886729728, 3232235520].sample + rand(2**16), Socket::AF_INET)
Most any RF1918 space is generated. Unfortunately, this will always produce 10.0.X.X addresses, but that should be fine for testing if one was looking for some address variety in a not too terrible looking one-liner format.
A major benefit of something like this or Lass's method over Faker is there is reduced risk for accidental taxing of someone's Internet resources if the code attempts to reach out to the random address for some reason.
To generate valid IP addresses within a reasonable network range (e.g. 10.0.0.0/24 or 2001:db8::/64), do this:
require 'ipaddr'
ipv4 = IPAddr.new("10.0.0.0/24", Socket::AF_INET) | IPAddr.new(rand(2**(32-24)),Socket::AF_INET)
ipv6 = IPAddr.new("2001:db8:cafe:babe::/64", Socket::AF_INET6) | IPAddr.new(rand(2**(128-64)),Socket::AF_INET6)
This can be generalized to any subnet:
subnet = "192.168.100.0"
prefix = 24
ipv4 = IPAddr.new("#{subnet}/#{prefix}", Socket::AF_INET) | IPAddr.new(rand(2**(32-prefix)),Socket::AF_INET)

Resources