Skip to content

Instantly share code, notes, and snippets.

@nhtzr
nhtzr / Wizard.java
Created March 6, 2024 17:49
Example for a wizard made using cardLayout in java swing
import javax.swing.*;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Wizard {
private final CardLayout wizardCardLayout;
@nhtzr
nhtzr / fh1-osx.md
Created May 13, 2023 21:24
[Guide] Running FH1 Fear and Hunger on OSX

Hello. I bought this game for mac, and I got it running with save files:

  • Download the mac build for the game, unzip it note: We will source the game files from here
  • Download the latest nwjs.io https://dl.nwjs.io/v0.76.0/nwjs-v0.76.0-osx-x64.zip, unzip it note: This is the 64bit executable that osx requires, we will copy the game contents on to here
  • Copy over 'Downloads/Fear & Hunger_MAC/Game.app/Contents/Resources/app.nw' to 'Downloads/nwjs-v0.76.0-osx-x64/nwjs.app/Contents/Resources/'
    • Optional: Download pixi.js v4.8.9 https://pixijs.download/v4.8.9/pixi.js
    • Optional: Copy it to 'Downloads/nwjs-v0.76.0-osx-x64/nwjs.app/Contents/Resources/app.nw/js/libs' and choose replace when OSX asks.
  • Open TextEdit use it to edit 'Downloads/nwjs-v0.76.0-osx-x64/nwjs.app/Contents/Resources/app.nw/package.json'
function su {
Start-Process powershell.exe -Verb RunAs -Args "-executionpolicy bypass -noexit -command Set-Location \`"$PWD\`"; `$env:Path += \`";$env:USERPROFILE\scoop\shims\`"; `$env:SCOOP = \`"$env:USERPROFILE\scoop\`"; `$env:XDG_CONFIG_HOME = \`"$env:USERPROFILE\.config\`"; `$env:SCOOP_STARTMENU = \`"$([Environment]::GetFolderPath('startmenu'))\`"; $args; robocopy `$([System.IO.Path]::Combine([Environment]::GetFolderPath('startmenu'), 'Programs', 'Scoop Apps'))` `$([System.IO.Path]::Combine(`$env:SCOOP_STARTMENU`, 'Programs', 'Scoop Apps', 'Admin'))` *.lnk /XO /PURGE;"
}
@nhtzr
nhtzr / kustomization.yml
Created January 29, 2021 18:57
replace apiversion using kustomize
resources:
- resource.yml
patches:
- target:
group: networking.istio.io
version: v1alpha3
patch: >
- op: replace
path: /apiVersion
value: networking.istio.io/v1beta1
@nhtzr
nhtzr / __shell_invocation
Last active October 21, 2020 18:19
latest github tags
# for latest 0.x releases
$ for i in 2 3 4 5; do github-gql ~/tags.gql v0.$i. kubesvc-plugin | jq -r 'try(.repository.refs.edges[].node.name)'; done
#> v0.2.3
#> v0.3.13
#> v0.4.8
#> v0.5.0-rc.14
@nhtzr
nhtzr / proxy.conf
Created May 12, 2020 18:50
basic reversproxy for nginx
http {
server {
listen *:80;
location / {
proxy_pass http://localhost:8080/;
}
}
}
/Applications/kitty.app/Contents/MacOS/kitty --title nvim --override maxos_quit_when_last_window_closed=yes --instance-group=nvim /bin/zsh -i -c 'exec nvim'
public class LongestPalindrome {
public String longestPalindrome(String s) {
if(s.length() <= 1) return s;
int top = s.length() - 1;
char[] input = s.toCharArray();
String palindrome = String.valueOf(s.charAt(0));
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
@nhtzr
nhtzr / askpass
Created March 20, 2020 01:01
askpass for osx
#!/usr/bin/env sh
osascript -e "
on GetCurrentApp()
tell application \"System Events\"
set _app to item 1 of (every process whose frontmost is true)
return name of _app
end tell
end GetCurrentApp
set _app to GetCurrentApp()
tell application _app