Readit News logoReadit News
jsrn commented on Oil Demand for Cars Is Already Falling   bloomberg.com/opinion/art... · Posted by u/jseliger
ToFab123 · 7 years ago
Think of an item, that you're purchased within the last couple of years, that was not made from oil but was manufactured in Russia. Ok, I wait. You can't think of any? OK, then what about from of the Arab speaking countries? Yes. I can wait. Take your time.

I hope those countries have a plan B for when the majority of the world's car run on something else than oil.

jsrn · 7 years ago
Does software count as an 'item' for you? If yes, for me (and I guess many others here) it would be various products of JetBrains, also Kotlin (even if I did not pay for that one directly) and OCR software from Abbyy. Also did not pay for, but use daily: nginx.
jsrn commented on Useful Perl one-liners (2013)   catonmat.net/download/per... · Posted by u/kawera
paulmd · 9 years ago
They're functionally interchangeable for simple usage (minus some perl-specific stuff like PCRE).

As I note below, escape behavior is a little different because sed wants you to escape +'s to have the normal regex semantics ("one or more matches"). And I actually think Perl is correct here and you should only need to escape those characters if you want literal matches, but I have a weird environment (Cygwin) and it's possible the sed build there is a little messed up.

The major difference for me is that Perl can match across multiple lines using the -0777 flag. I've been doing a lot of regex-based mass manipulation of source code lately and most people write functions across multiple lines. You can't do that with sed without multi-line appending and it gets really ugly really fast. Sed is pretty much just single line matches only.

For example, I had 100-odd classes with getters for certain values but not setters. So I did:

  grep -rle "getAddTime" | while read line; do if ! grep -q "setAddTime" $line ; then echo $line; perl -i -0777 -pe 's/public\s+Date\s+getAddTime\s*\(\s*\)\s*\{[\s\w=;]+\}/$&\n\n  public void setAddTime(Date addTime) { this.addTime = addTime; }/' $line; fi done
translation: look for files that contain getAddTime, if they do not contain setAddTime then find the string "public Date getAddTime() {...} and append the setter after that". There are a few edge cases you could hit there but it was close enough to work on my codebase.

I wish Perl would do an inplace edit of a file without creating a backup, though. I am under source control so there's no harm in just operating right on the files. It's not the end of the world to follow up with a rm -r *.bak I guess, but it's annoying. At least they're in my git-ignore which helps a little.

jsrn · 9 years ago
Regarding this: "I wish Perl would do an inplace edit of a file without creating a backup, though."

    $ perldoc perlrun
(or http://perldoc.perl.org/perlrun.html)

says:

> If no extension is supplied, and your system supports it, the original file is kept open without a name while the output is redirected to a new file with the original filename. When perl exits, cleanly or not, the original file is unlinked.

Which system are you using? With macOS and Linux, I get no automatic .bak extension when not providing a backup suffix, i.e. it behaves like you want under these systems.

Update: Apparently, anonymous files are not supported by Windows: http://stackoverflow.com/a/30539016 which would explain the behaviour you describe.

jsrn commented on Show HN: Anycomplete   github.com/nathancahill/h... · Posted by u/nathancahill
kevinastone · 9 years ago
Would think jq[0] is more suitable if you're going to install a cli json parser.

[0]: https://stedolan.github.io/jq/

jsrn · 9 years ago
Here is the command with jq instead of json_pp

    $ curl -sS 'https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=aurora' | jq . | gsed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'
(see my other comment about gsed vs sed)

jsrn commented on Show HN: Anycomplete   github.com/nathancahill/h... · Posted by u/nathancahill
jxy · 9 years ago
If you have your shell ready,

    curl -sS 'https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=aurora' \
        | json_pp | sed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'

jsrn · 9 years ago
Nice!

To run this with macOS, I had to use the GNU version of sed. I installed it with

    $ brew install gnu-sed
And it is then called with 'gsed' instead of 'sed'.

As an avid Perl programmer, I had json_pp in my $PATH - for everyone else - it is here: https://metacpan.org/pod/JSON::PP

You can install it with cpanm:

    $ cpanm JSON::PP
If you don't have cpanm, you can install it with

    $ curl -L https://cpanmin.us | perl - App::cpanminus
The modified command line from above then becomes:

    $ curl -sS 'https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=aurora' \
        | json_pp | gsed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'
Here is a little Bash function to encapsulate this:

    $ function c() { curl -sS "https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=$1" | json_pp | gsed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'; }
Which then allows you to use it like this:

    $ c hacker
    hacker news
    hacker typer
    hackerrank
    hackerman
    hackers movie
    hacker fare
    hackerone
    hackers cast
    hacker pschorr
For spaces in your query, use a '+':

    $ c New+York
    new york times
    new york and company
    new york giants
    new york post
    new york daily news
    new york weather

jsrn commented on Regular Expression That Checks If A Number Is Prime   iluxonchik.github.io/regu... · Posted by u/iluxonchik
jsrn · 9 years ago
Invented in 1998 by Perl hacker Abigail:

http://neilk.net/blog/2000/06/01/abigails-regex-to-test-for-...

(check out Abigail's other JAPHs if you like stuff like this)

jsrn commented on 7 Reasons our app costs $99.99   blog.httpwatch.com/2014/0... · Posted by u/ryanmcdonough
wilsynet · 12 years ago
Because that would violate the Apple rules (and also be practically infeasible for technical reasons).

You can officially (as a matter of policy and enforced by iOS) distribute apps in 3 ways:

1. Through the App Store

2. As an enterprise developer distributing apps to employees of the same company through an enterprise App Store to an enterprise enrolled iOS device

3. As a developer to a test device where the test device is 1 out of 100 registered devices in your Apple developer account

The only other alternative I'm aware of is to jailbreak the device and distribute via Cydia.

jsrn · 12 years ago
Regarding your (2.) - just to clarify this for others: With an enterprise provisioning profile, you can deploy your app to an arbitrary number of devices. These devices do not need to be known before via UDID (as with normal OTA provisioning). You can just upload the app to a server and ask people to download. So the devices do not technically have to belong to the same organization (even if this is perhaps Apple's intent). E.g., a friend of mine uses an enterprise account which they aquired for their university to deploy an app for a study (for data gathering). The subjects who install the app and enter their data are not all part of the university. Apple was informed about this use case and they did not have anything against it.

But, AFAIK Apple centrally checks the validity of the profile with each download and thus they are certainly able to detect if you use your enterprise profile to circumvent the appstore.

u/jsrn

KarmaCake day911February 21, 2007View Original