HN isn't much better. I've emailed them asking for my data to be removed, as is my right as an EU citizen and dang simply refused saying it wouldn't be fair to other users. As if that overrides the law.
884 karma · joined September 28, 2022
HN isn't much better. I've emailed them asking for my data to be removed, as is my right as an EU citizen and dang simply refused saying it wouldn't be fair to other users. As if that overrides the law.
My keyboard does not have a cmd key, and I am not a mobile user.
Dang posted the links to the previous stories, didn't mark the post as a dupe or say anything about it being a dupe. Because it's not. Then two hours later it silently got deleted.
> I do not understand how this post is number one. Are you saying Hacker News can promote certain posts to the top and it is not organically curated?
Absolutely, yes. The mods can influence the ranking directly and they have openly talked about this. If you search https://hn.algolia.com/ for "penalized", "demoted" or "promoted" you will find discussions regarding this.
---
Since dang banned me from posting new replies:
> Maybe you haven’t been here long enough to have read the FAQ or know that generally all dupes from 3-4 days ago are marked, and only allowed after at least several months?
I've been here for many years. I just make a new account periodically. Maybe you haven't been paying enough attention to see the difference in behavior that dang exhibits when he wants to censor something? Notice how he's usually all over the comments explaining why something was removed as dupe, but now there is nothing except him linking to the older posts (https://news.ycombinator.com/item?id=34559614), waiting for an hour or two, and then silently deleting the new one.
Not to mention that the subject of the post is completely different. The latest post is about the documentary being removed from archive.org at the request of the BBC. None of the earlier posts cover this.
This doesn't mean anything. If an unsecured SSH server is connected to the internet that lets anyone who connects to it in and gives them a root shell, it is still illegal to 'hack' that machine. The law cares about intent, not technicalities.
edit: Since HN decided to break with "You're posting too fast. Please slow down. Thanks." again, banning me from replying: This is obviously just an example intended to show that the law cares more about intent than technical measures.
@dang Calm down dude.
> my assistant does my bidding
It doesn't. Try asking it how to make a bomb, then search for the same on youtube. One of the two yields a useful result, the other gives a moralistic lecture.
Oops :)
When pressing Ctrl+Enter, did you see the green "Loaded!" notification in the bottom right? If so, then I guess installing the Kotlin plugin worked.
> Opening the menu with Ctrl+Shift+A doesn't show the bulk refactor script
The Ctrl+Shift+A menu from the default keymap that I'm talking about is the "Actions" dialog. You can also get there via "Navigate -> Search Everywhere" and then selecting the "Actions" tab (or just searching in All).
Also you only have to select a single folder/package and it will be processed recursively. I did not test what happens when you select multiple folders. Might be fine, might explode.
edit: Just realized the script I pasted here does not emit the "Loaded!" log message on load. So disregard those comments. If you want to verify it loads correctly, add this as the last line:
log("Loaded!")
edit: HN rate limited my account again, so I'm not allowed to post any new comments for the next few hours. Good luck!If you do wind up using this script and want to modify it, it is helpful to read https://plugins.jetbrains.com/docs/intellij/psi.html & to install the PsiViewer plugin from the marketplace.
Then run the script like this:
1. In IDEA: Tools -> IDE Scripting Console -> Kotlin
2. Paste in the script
3. Ctrl+A, Ctrl+Enter to load the script. This should show a green "Loaded!" notification
4. Select a folder containing the classes in the Project window
5. Press Ctrl+Shift+A to open action menu
6. Search for Bulk refactor and select it
Also please note the first version of the script had a bug that would open confirmation dialogues for some refactorings, so see the edited script.
The (meager) docs on scripting: https://www.jetbrains.com/help/idea/ide-scripting-console.ht.... The plugin docs & intellij source code (especially the unit tests) are a better source of information.
And here's a script that will use intellij's refactoring to rename all classes recursively in a directory to add the prefix Renamed, correctly dealing with references & renaming files if necessary:
@file:Suppress("NAME_SHADOWING")
import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.keymap.KeymapManager
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.psi.*
import com.intellij.psi.search.*
import com.intellij.refactoring.rename.RenameProcessor
import com.intellij.util.ThrowableConsumer
import java.io.PrintWriter
import java.io.StringWriter
import javax.swing.KeyStroke
// Usage: In IDEA: Tools -> IDE Scripting Console -> Kotlin
// Ctrl+A, Ctrl+Enter to run the script
// Select folder containing target classes, Ctrl+Shift+A to open action menu, search for Bulk refactor
//<editor-fold desc="Boilerplate">
val b = bindings as Map<*, *>
val IDE = b["IDE"] as com.intellij.ide.script.IDE
fun registerAction(
name: String,
keyBind: String? = null,
consumer: ThrowableConsumer<AnActionEvent, Throwable>
) {
registerAction(name, keyBind, object : AnAction() {
override fun actionPerformed(event: AnActionEvent) {
try {
consumer.consume(event);
} catch (t: Throwable) {
val sw = StringWriter()
t.printStackTrace(PrintWriter(sw))
log("Exception in action $name: $t\n\n\n$sw", NotificationType.ERROR)
throw t
}
}
});
}
fun registerAction(name: String, keyBind: String? = null, action: AnAction) {
action.templatePresentation.text = name;
action.templatePresentation.description = name;
KeymapManager.getInstance().activeKeymap.removeAllActionShortcuts(name);
ActionManager.getInstance().unregisterAction(name);
ActionManager.getInstance().registerAction(name, action);
if (keyBind != null) {
KeymapManager.getInstance().activeKeymap.addShortcut(
name,
KeyboardShortcut(KeyStroke.getKeyStroke(keyBind), null)
);
}
}
fun log(msg: String, notificationType: NotificationType = NotificationType.INFORMATION) {
log("Scripted Action", msg, notificationType)
}
fun log(
title: String,
msg: String,
notificationType: NotificationType = NotificationType.INFORMATION
) {
Notifications.Bus.notify(
Notification(
"scriptedAction",
title,
msg,
notificationType
)
)
}
//</editor-fold>
registerAction("Bulk refactor") lambda@{ event ->
val project = event.project ?: return@lambda;
val psiElement = event.getData(LangDataKeys.PSI_ELEMENT) ?: return@lambda
log("Bulk refactor for: $psiElement")
WriteCommandAction.writeCommandAction(event.project).withGlobalUndo().run<Throwable> {
psiElement.accept(object : PsiRecursiveElementWalkingVisitor() {
override fun visitElement(element: PsiElement) {
super.visitElement(element);
if (element !is PsiClass) {
return
}
if(element.name?.startsWith("Renamed") == false) {
log("Renaming $element")
// arg4 = isSearchInComments
// arg5 = isSearchTextOccurrences
val processor = object : RenameProcessor(project, element, "Renamed" + element.name, false, false) {
override fun isPreviewUsages(usages: Array<out UsageInfo>): Boolean {
return false
}
}
processor.run()
}
}
})
}
}
If your project is large this will temporarily freeze intellij since it doesn't properly run on the background thread but just give it a minute.By the way, this should work on all languages that IntelliJ has a language plugin for, not just Java.
Edit: Modified script to override isPreviewUsages to prevent intellij from opening confirmation dialogs
~/tmp/foo git init repo1
Initialized empty Git repository in /home/user/tmp/foo/repo1/.git/
~/tmp/foo cd repo1
tmp/foo/repo1 ‹master› echo hi > hi
tmp/foo/repo1 ‹master› git add hi
tmp/foo/repo1 ‹master*› git commit -m hi
[master (root-commit) d0cf572] hi
1 file changed, 1 insertion(+)
create mode 100644 hi
tmp/foo/repo1 ‹master› cd ..
~/tmp/foo git clone repo1 repo2
Cloning into 'repo2'...
done.
~/tmp/foo cd repo1
tmp/foo/repo1 ‹master› echo hi2 > hi
tmp/foo/repo1 ‹master*› git add hi
tmp/foo/repo1 ‹master*› git commit -m hi2
[master 3a82bdc] hi2
1 file changed, 1 insertion(+), 1 deletion(-)
tmp/foo/repo1 ‹master› git checkout -b someotherbranch
Switched to a new branch 'someotherbranch'
tmp/foo/repo1 ‹someotherbranch› git
tmp/foo/repo1 ‹someotherbranch› echo otherchange > otherchange
tmp/foo/repo1 ‹someotherbranch› git add otherchange
tmp/foo/repo1 ‹someotherbranch*› git commit -m "otherchange"
[someotherbranch 99ec880] otherchange
1 file changed, 1 insertion(+)
create mode 100644 otherchange
tmp/foo/repo1 ‹someotherbranch› cd ../repo2
tmp/foo/repo2 ‹master› git remote add upstream ../repo1
tmp/foo/repo2 ‹master› git fetch upstream
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), 448 bytes | 448.00 KiB/s, done.
From ../repo1
* [new branch] master -> upstream/master
* [new branch] someotherbranch -> upstream/someotherbranch
tmp/foo/repo2 ‹master› git checkout master
Already on 'master'
Your branch is up to date with 'origin/master'.
tmp/foo/repo2 ‹master› git rebase upstream/master
Successfully rebased and updated refs/heads/master.
tmp/foo/repo2 ‹master› git switch someotherbranch
branch 'someotherbranch' set up to track 'upstream/someotherbranch'.
Switched to a new branch 'someotherbranch'If you think you can do better, please do! Let me know when you've gotten a few projects to switch over and I'll gladly learn that, too. Not a lot of projects using mercurial these days.