Stories
Slash Boxes
Comments

SoylentNews is people

Log In

Log In

Create Account  |  Retrieve Password


Trump and Duterte's Drug War Bromance

Posted by takyon on Sunday December 04 2016, @01:52AM (#2158)
6 Comments

Some BBC Election Stories

Posted by takyon on Tuesday November 08 2016, @05:04PM (#2130)
18 Comments

Retro Data Structures

Posted by mechanicjay on Thursday November 03 2016, @05:38AM (#2125)
5 Comments
Code

Reposted from my blog: Operation Sysadmin | Retro Data Structures

One of the more fun things I do with my spare time is to play around with old computers. Specifically, I enjoy my Atari 800. I recently started thinking about a small game to write on the machine, something with a small map, which you can explore. Think Zork, on a very, very limited scale. This is mostly an exercise for me to see if I could pull this off in Atari BASIC.

If you were to make, say a 3x3 grid with a bunch of data attached to it, without getting all Object Oriented, you might choose simple data structure such as a 2-dimensional array, to retrieve data associated with your particular x,y coordinates on the map. A graphical representation of this data might look like this:
      1             2                3
  1 The start   A treasure!        A river.
  2 A monster!   Inscribed Rock   The wizard.
  3 A forest.   A bird.           Home

Atari BASIC, has three basic data types, number, character, and boolean. It also has arrays, you can make an array of numbers which is a standard thing, even today, or an array of letters. You may be tempted to call this a string, and it is referred to as such, but if you think of strings in Atari BASIC as character arrays, you're life starts getting easier. You can also make a mufti-dimensional array of numbers. A think that you absolutely cannot do, however, is make a mufti-dimensional character array, a matrix of strings if you will, at least not in a basic straight forward way. This limitation hit me pretty hard. Living in the modern age, I'm used to slamming together data-types in a multitude of different structures, without worrying too much about it.

So, given this limitation, how do you get all that string data into a data structure that you can reference by some sort of position? One place where Atari BASIC helps us out is that I can reference positions in strings and substrings quite easily, which turns out to be the ugly key we need.

Say, I want an array to hold 3 things. myarray$="Mary Bob I really like dogs, they are my favorite." If I wanted to get the word "Bob" out of this, I'd call for myarray$(6,9). Mary would be myarray$(1,4), the sentence would be myarray$(9,51). The issue of course is that all the lengths are irregular. I can't simply retrieve the nth element without knowing it's position in the larger string. But, what if we make the string lengths regular? First determine what the longest string you're going to allow is. In this case the sentence about dogs is 42 characters. Then, multiple, by the number of elements you'll be holding. 3*42=126, so declare a string 126 characters long. Something like the following BASIC code:

10 ELEM=3
20 MAXLEN=42
30 DIM MYARRAY$(ELEM*MAXLEN)

Now, you can reference the different elements by using MAXLEN as a multiplier to get the proper positions. Bob would be MYARRAY$(43,84), or MYARRAY$(MAXLEN,MAXLEN*2-1)
Mary, would be (1,MAXLEN-1). We can wrap the whole idea in a subroutine (No functions here kids!) make the positional calculations:


40 REM GET THE 2nd ELEMENT
50 GET=2
60 GOSUB 100
100 REM ELEMENT RETRIEVAL SUBROUTINE
110 START=GET*MAXLEN-MAXLEN
120 END=START+MAXLEN-1
130 PRINT MYARRAY$(START,END)
140 RETURN

The interesting thing to me about this approach is how incredibly space inefficient it is, especially noticeable when you're working on a machine with 48K of memory. It's also an good reminder about the kind of stuff that has to go on under the covers in our nice modern languages to make them so comfortable to work with.

Remember though, I'm interested in a matrix of strings! It turns out that with a little math you can extend this scheme to make a 2 dimensional array of strings as well. All it takes is another multiplier in there, which incidentally makes this an order of magnitude less efficient.

10 ROW=3
20 COL=3
30 MAXLEN=50
40 DIM MYMATRIX$(ROW*COL*MAXLEN)
50 REM POSITION
60 X=2,Y=1
70 GOSUB 100
100 REM MATRIX RETRIEVAL SUBROUTINE
110 START=X*MAXLEN-MAXLEN+Y*MAXLEN-MAXLEN-1
120 END=START+MAXLEN-1
130 PRINT ARRAY(START,END)
140 RETURN

In this way by manipulating the X and Y variables, and calling the subroutine we can retrieve different "cells" of data in our matrix.

Go ahead and stare at that second basic program for a few minutes until the math sinks in. The start position is calculated just like in the 1 dimensional example, with an additional Y position offset.

This approach will work decently well, for smaller grids with not too much data. Say a 3x3 grid, with each "cell" containing 255 characters or so, results in a use of just under 2.5K. What if you wanted a larger map though, say a 9x9, well that's 20K, almost 1/2 your memory.

The strategy for dealing with this, is to break your 9x9 down into 9 different 3x3 grids. Since this, in theory a map that we are traversing, imagine another variable to hold your current "grid" number, and subroutine to calculate what grid you'll be in when you move. If it's different, load the new grid grid information from disk. In this way, you can keep the memory foot print pretty small, and 2.5K loads pretty quick from a floppy drive.

When I finish up this exercise I will post the code so you can bask in its glory.

Oculus VR vs ZeniMax

Posted by takyon on Monday October 31 2016, @10:55PM (#2122)
0 Comments
Business

Oculus VR made "factually inaccurate" statements in ZeniMax lawsuit, forensic analyst says

A recently-granted motion in the lawsuit between ZeniMax Media and Oculus VR suggests that the case could be about to get very interesting, and not in a way that's good for Oculus. The motion to "permit disclosure of any 'demonstrably inaccurate' representations made to court," as reported by Polygon, indicates that an independent expert investigating the case found sworn statements that are "factually incorrect," and that "critical log files" on one of John Carmack's hard drives were deleted prior to its collection as evidence.

I'm too lazy to give this one the research needed to produce a coherent submission, since I haven't been following the case.

script to stop windows ten updates

Posted by Runaway1956 on Friday October 28 2016, @02:41PM (#2120)
2 Comments
Code

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

/*
https://technet.microsoft.com/en-us/windows/release-info
This site contains latest version info etc.,
To be compared to CurrentBuild and UBR registry entries contained in:
        HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion
LastAutoAppUpdateSearchSuccessTime in:
        HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate
LastScheduledRetryTime in above.
*/

;Parameters
;MS Win10 release info page https://technet.microsoft.com/en-us/windows/release-info
LatestUpdateURL := "https://winrelinfo.blob.core.windows.net/winrelinfo/en-US.html"

whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", LatestUpdateURL, true)
whr.Send()
whr.WaitForResponse()
releaseinfo := whr.ResponseText

RegRead, ReleaseId, HKLM, SOFTWARE\Microsoft\Windows NT\CurrentVersion, ReleaseId
RegRead, CurrentBuild, HKLM, SOFTWARE\Microsoft\Windows NT\CurrentVersion, CurrentBuild
RegRead, UBR, HKLM, SOFTWARE\Microsoft\Windows NT\CurrentVersion, UBR

needle := "\s*" . ReleaseId . "\s*\s*\s*(" . CurrentBuild . "\." . UBR . ")\s*"

found := RegExMatch(releaseinfo, needle)
if (found) {
        MsgBox % "Your version of Windows 10: " . ReleaseId . "`nOS Build: " . CurrentBuild . "." . UBR . "`nThis is the latest version."
}
Else {
        MsgBox % "There may be updates available! Please turn on Windows Update Service!"
}

;UrlDownloadToFile, %LatestUpdateURL%, %A_ScriptDir%\release-info.html
;FileDelete, %A_ScriptDir%\release-info.html

;First, find CurrentBuild.UBR preceded by ReleaseId, if can't be found alert user!
;Second, check that UBR and CurrentBuild.xxx are the same!
; If same, alert user that they are up to date.
; If different, get KB# (or numbers, this could read the entried until it finds the UBR number) and give user a link so that they may read about the future update. Ask if user would like to update now, remind me later, or not right now
; If user decides to update, turn on windows update service.
; How do we know when to disable that pesky service? After the reboot? Perhaps add a script to the startup folder / registry that will disable windows update on the reboot.

===========================

No, I'm not the script writer. The guy who wrote it gave it to me. Here it is. And, I don't have a Win10 machine to test it on. No attribution - I guess he's AC.

Sasha Disses Barack on Snapchat

Posted by takyon on Thursday October 27 2016, @05:02PM (#2119)
4 Comments
/dev/random

I'm taking away your Air Force One privileges.

President Obama ridiculed on Snapchat by daughter Sasha

The president also mentioned that his own iPhone was limited to receiving emails and browsing the internet, and would not take photos, play music or make calls. "My rule has been throughout my presidency, that I assume that someday, some time, somebody will read this email," he said. "So, I don't send any email that at some point won't be on the front page of the newspapers."

US election 2016: Indians' verdict on Donald Trump's Hindi

An uncanny mixture: God, alcohol and even cannabis

A Stray: Finding and filming the real Somali immigrant experience

The Skype sex scam - a fortune built on shame

In pictures: Living off-grid

Posted by takyon on Tuesday October 25 2016, @11:27PM (#2117)
11 Comments

John Oliver Pinpoints Fake Opioid Crisis Statistic

Posted by takyon on Tuesday October 25 2016, @07:52AM (#2115)
0 Comments
News

John Oliver Pinpoints A Fake Statistic That Fueled The Opioid Crisis

In John Oliver’s latest segment on opioids during Last Week Tonight, he pulled up one of the key statistics pharmaceutical salespeople used to market prescription opioids to doctors in the 1990s: Less than 1 percent of patients taking opioids become addicted to painkillers. That figure is completely inaccurate, of course, and as Oliver points out, it has a disturbing origin story.

Facebook Employees Argued for Censorship of Mr. Trump

Posted by takyon on Saturday October 22 2016, @09:58PM (#2112)
6 Comments
Digital Liberty

Somebody got triggered.

Facebook Employees Pushed to Remove Trump’s Posts as Hate Speech

Some of Republican presidential candidate Donald Trump’s posts on Facebook have set off an intense debate inside the social media company over the past year, with some employees arguing certain posts about banning Muslims from entering the U.S. should be removed for violating the site’s rules on hate speech, according to people familiar with the matter.

The decision to allow Mr. Trump’s posts went all the way to Facebook Inc. Chief Executive Mark Zuckerberg, who ruled in December that it would be inappropriate to censor the candidate, according to the people familiar with the matter. That decision has prompted employees across the company to complain on Facebook’s internal messaging service and in person to Mr. Zuckerberg and other managers that it was bending the site’s rules for Mr. Trump, and some employees who work in a group charged with reviewing content on Facebook threatened to quit, the people said.

Facebook employees argued Trump's posts should be banned as hate speech

32% Globally Think Gay Marriage Should Be Legal

Posted by takyon on Tuesday October 18 2016, @07:49PM (#2108)
5 Comments
/dev/random

One in Three People Globally Think Gay Marriage Should Be Legal

Only 19 percent of respondents in Africa and 26 percent in Asia said they approved of same-sex marriage, against 35 percent in the Americas, 41 percent in Europe and 56 percent in Oceania the online survey found.

These divisions reflect that rights advocates in Africa and Asia have focused on more pressing issues, such as fighting discrimination against gays rather than promoting acceptance of same-sex marriage, said study co-author Aengus Carroll.

"This is so far off the agenda for Africa and Asia," Carroll told the Thomson Reuters Foundation.