Skip to content

Instantly share code, notes, and snippets.

@ralphie02
Last active January 11, 2024 23:52
Show Gist options
  • Save ralphie02/626b6d937aee4e7153ac0491c3f3781a to your computer and use it in GitHub Desktop.
Save ralphie02/626b6d937aee4e7153ac0491c3f3781a to your computer and use it in GitHub Desktop.
windows-stuff

Remove Annoyingly persistend windows.old directory (ref):

RD /S /Q %SystemDrive%\windows.old

Windows:

  • admin cmd: reg add hkcu\Software\Policies\Microsoft\Windows\Explorer /v NoWindowMinimizingShortcuts /t REG_DWORD /d 0x1 ## http://www.techunboxed.com/2015/07/how-to-disable-aero-shake-in-windows-10.html

  • encryption: group policy > Computer Configuration\Administrative Templates\Windows Components\BitLocker Drive Encryption

  • install psql in windows then run in linux: psql -p 5432 -h localhost -U postgres

sudo usermod -aG docker $USER
mkdir /mnt/c/Users/<user>/Dev
sudo ln -s /mnt/c /
ln -s /mnt/c/Users/<user>/Dev/ ~/

Useful:

  • python-dev|python-pip|pip install sslyze|
  • change nested dir: https://stackoverflow.com/questions/4210042/how-to-exclude-a-directory-in-find-command
    • ie. find . -path "./.git*" -prune -o -print -type f -exec chmod 644 {} \;
  • find file with a given name: find <dir> -name <name>
  • Group Policy Editor: Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options
  • sudo mount -t drvfs '\server.name.ad\directory\dir' /mnt/dir/ -o metadata

s!ArAeSjDMUTzVsMsVn5w6LZO_4lJN0g

s!ArAeSjDMUTzVsMZMYp_-jhCF3hEPzw

1DeO9f2hjQLEksHIN6SOI80nvu44KXHI7

1JzCM9VMhV1Y6wAr0wa671nFuA1nc0T-C

s!ArAeSjDMUTzVsLUCfAmcC95V5ztcRA

1osSi2PF4bpFpEDZWbgQhAtbq-1IfVD3p

v4126

user changes to monokai:

// Documentation at https://www.sublimetext.com/docs/color_schemes.html
{
  "variables":
  {
    "blue": "lightseagreen",
  },
  "globals":
  {
    "background": "#111"
  },
  "rules":
  [
    // Stolen from Celeste.sublime-color-scheme
    {
      "scope": "source - comment - string - keyword - punctuation - storage - entity - source.css",
      "foreground": ["orangered", "hotpink"]
    },
    {
      "scope": "keyword.operator.assignment",
      "foreground": "white",
    },
    // ie. `private`, `attr_reader`
    {
      "scope": "keyword.other",
      "foreground": "gold",
    },
  ]
}

default monokai:

{
    "name": "Monokai",
    "author": "Sublime HQ Pty Ltd, Wimer Hazenberg",
    "variables":
    {
        "black": "hsl(0, 0%, 0%)",
        "black2": "hsl(60, 17%, 11%)",
        "black3": "hsl(70, 8%, 15%)",
        "blue": "hsl(190, 81%, 67%)",
        "grey": "hsla(55, 8%, 31%, 0.7)",
        "orange": "hsl(32, 98%, 56%)",
        "orange2": "hsl(30, 83%, 34%)",
        "orange3": "hsl(47, 100%, 79%)",
        "purple": "hsl(261, 100%, 75%)",
        "red": "hsl(0, 93%, 59%)",
        "red2": "hsl(338, 95%, 56%)",
        "white": "hsl(0, 0%, 97%)",
        "white2": "hsl(60, 36%, 96%)",
        "white3": "hsl(60, 30%, 96%)",
        "yellow": "hsl(54, 70%, 68%)",
        "yellow2": "hsl(80, 76%, 53%)",
        "yellow3": "hsl(60, 12%, 79%)",
        "yellow4": "hsl(55, 11%, 22%)",
        "yellow5": "hsl(50, 11%, 41%)"
    },
    "globals":
    {
        "foreground": "var(white3)",
        "background": "var(black3)",
        "caret": "color(var(white2) alpha(0.9))",
        "block_caret": "color(var(white2) alpha(0.2))",
        "block_caret_border": "color(var(white2) alpha(0.8))",
        "invisibles": "color(var(white3) alpha(0.35))",
        "line_highlight": "var(yellow4)",
        "selection": "var(grey)",
        "selection_border": "var(black2)",
        "misspelling": "var(red2)",
        "active_guide": "color(var(orange2) alpha(0.69))",
        "find_highlight_foreground": "var(black)",
        "find_highlight": "var(orange3)",
        "brackets_options": "underline",
        "brackets_foreground": "color(var(white3) alpha(0.65))",
        "bracket_contents_options": "underline",
        "bracket_contents_foreground": "color(var(white3) alpha(0.65))",
        "tags_options": "stippled_underline",
    },
    "rules":
    [
        {
            "name": "Comment",
            "scope": "comment",
            "foreground": "var(yellow5)"
        },
        {
            "name": "String",
            "scope": "string",
            "foreground": "var(yellow)"
        },
        {
            "name": "Number",
            "scope": "constant.numeric",
            "foreground": "var(purple)"
        },
        {
            "name": "Number suffix",
            "scope": "storage.type.numeric",
            "foreground": "var(blue)",
            "font_style": "italic"
        },
        {
            "name": "Built-in constant",
            "scope": "constant.language",
            "foreground": "var(purple)"
        },
        {
            "name": "User-defined constant",
            "scope": "constant.character, constant.other",
            "foreground": "var(purple)"
        },
        {
            "name": "Variable",
            "scope": "variable"
        },
        {
            "name": "Keyword",
            "scope": "keyword - (source.c keyword.operator | source.c++ keyword.operator | source.objc keyword.operator | source.objc++ keyword.operator), keyword.operator.word, source.ruby keyword.declaration",
            "foreground": "var(red2)"
        },
        {
            "name": "Annotation Punctuation",
            "scope": "punctuation.definition.annotation",
            "foreground": "var(red2)"
        },
        {
            "name": "JavaScript Dollar",
            "scope": "variable.other.dollar.only.js",
            "foreground": "var(red2)"
        },
        {
            "name": "Storage",
            "scope": "storage",
            "foreground": "var(red2)"
        },
        {
            "name": "Storage type",
            "scope": "storage.type",
            "foreground": "var(blue)",
            "font_style": "italic"
        },
        {
            "name": "Entity name",
            "scope": "entity.name - (entity.name.filename | entity.name.section | entity.name.tag | entity.name.label)",
            "foreground": "var(yellow2)"
        },
        {
            "name": "Inherited class",
            "scope": "entity.other.inherited-class",
            "foreground": "var(yellow2)",
            "font_style": "italic"
        },
        {
            "name": "Function argument",
            "scope": "variable.parameter - (source.c | source.c++ | source.objc | source.objc++)",
            "foreground": "var(orange)",
            "font_style": "italic"
        },
        {
            "name": "Language variable",
            "scope": "variable.language",
            "foreground": "var(orange)",
            "font_style": "italic"
        },
        {
            "name": "Tag name",
            "scope": "entity.name.tag",
            "foreground": "var(red2)"
        },
        {
            "name": "Tag attribute",
            "scope": "entity.other.attribute-name",
            "foreground": "var(yellow2)"
        },
        {
            "name": "Function call",
            "scope": "variable.function, variable.annotation",
            "foreground": "var(blue)"
        },
        {
            "name": "Library function",
            "scope": "support.function, support.macro",
            "foreground": "var(blue)"
        },
        {
            "name": "Library constant",
            "scope": "support.constant",
            "foreground": "var(blue)"
        },
        {
            "name": "Library class/type",
            "scope": "support.type, support.class",
            "foreground": "var(blue)",
            "font_style": "italic"
        },
        {
            "name": "Library variable",
            "scope": "support.other.variable"
        },
        {
            "name": "Invalid",
            "scope": "invalid",
            "foreground": "var(white2)",
            "background": "var(red2)"
        },
        {
            "name": "Invalid deprecated",
            "scope": "invalid.deprecated",
            "foreground": "var(white2)",
            "background": "var(purple)"
        },
        {
            "name": "JSON String",
            "scope": "meta.structure.dictionary.json string.quoted.double.json",
            "foreground": "var(yellow3)"
        },
        {
            "name": "YAML String",
            "scope": "string.unquoted.yaml",
            "foreground": "var(white3)"
        },
        {
            "name": "diff.header",
            "scope": "meta.diff, meta.diff.header",
            "foreground": "var(yellow5)"
        },
        {
            "name": "markup headings",
            "scope": "markup.heading",
            "font_style": "bold"
        },
        {
            "name": "markup headings",
            "scope": "markup.heading punctuation.definition.heading",
            "foreground": "var(orange)"
        },
        {
            "name": "markup h1",
            "scope": "markup.heading.1 punctuation.definition.heading",
            "foreground": "var(red2)"
        },
        {
            "name": "markup links",
            "scope": "markup.underline.link",
            "foreground": "var(blue)"
        },
        {
            "name": "markup bold",
            "scope": "markup.bold",
            "font_style": "bold"
        },
        {
            "name": "markup italic",
            "scope": "markup.italic",
            "font_style": "italic"
        },
        {
            "name": "markup underline",
            "scope": "markup.underline",
            "font_style": "underline"
        },
        {
            "name": "markup bold/italic",
            "scope": "markup.italic markup.bold | markup.bold markup.italic",
            "font_style": "bold italic"
        },
        {
            "name": "markup bold/underline",
            "scope": "markup.underline markup.bold | markup.bold markup.underline",
            "font_style": "bold underline"
        },
        {
            "name": "markup italic/underline",
            "scope": "markup.underline markup.italic | markup.italic markup.underline",
            "font_style": "italic underline"
        },
        {
            "name": "markup bold/italic/underline",
            "scope": "markup.bold markup.italic markup.underline | markup.bold markup.underline markup.italic | markup.italic markup.bold markup.underline | markup.italic markup.underline markup.bold | markup.underline markup.bold markup.italic | markup.underline markup.italic markup.bold",
            "font_style": "bold italic underline"
        },
        {
            "name": "markup hr",
            "scope": "punctuation.definition.thematic-break",
            "foreground": "var(yellow5)"
        },
        {
            "name": "markup blockquote",
            "scope": "markup.quote punctuation.definition.blockquote",
            "foreground": "var(yellow5)"
        },
        {
            "name": "markup bullets",
            "scope": "markup.list.numbered.bullet",
            "foreground": "var(purple)"
        },
        {
            "name": "markup bullets",
            "scope": "markup.list.unnumbered.bullet | (markup.list.numbered punctuation.definition)",
            "foreground": "color(var(white) alpha(0.67))"
        },
        {
            "name": "markup code",
            "scope": "markup.raw",
            "background": "color(var(white) alpha(0.094))"
        },
        {
            "name": "markup punctuation",
            "scope": "markup.raw punctuation.definition.raw",
            "foreground": "color(var(white) alpha(0.67))"
        },
        {
            "name": "markup punctuation",
            "scope": "text & (punctuation.definition.italic | punctuation.definition.bold | punctuation.definition.raw | punctuation.definition.link | punctuation.definition.metadata | punctuation.definition.image | punctuation.separator.table-cell | punctuation.section.table-header | punctuation.definition.constant)",
            "foreground": "color(var(white) alpha(0.67))"
        },
        {
            "name": "diff.deleted",
            "scope": "markup.deleted",
            "foreground": "var(red2)"
        },
        {
            "name": "diff.inserted",
            "scope": "markup.inserted",
            "foreground": "var(yellow2)"
        },
        {
            "name": "diff.changed",
            "scope": "markup.changed",
            "foreground": "var(yellow)"
        },
        {
            "scope": "constant.numeric.line-number.find-in-files - match",
            "foreground": "color(var(purple) alpha(0.63))"
        },
        {
            "scope": "entity.name.filename",
            "foreground": "var(yellow)"
        },
        {
            "scope": "message.error",
            "foreground": "var(red)"
        },

        {
            "scope": "diff.deleted",
            "background": "hsla(338, 50%, 56%, 0.15)",
            "foreground_adjust": "l(+ 5%)"
        },
        {
            "scope": "diff.deleted.char",
            "background": "hsla(338, 65%, 56%, 0.30)",
            "foreground_adjust": "l(+ 10%)"
        },
        {
            "scope": "diff.inserted",
            "background": "hsla(80, 50%, 53%, 0.15)",
            "foreground_adjust": "l(+ 5%)"
        },
        {
            "scope": "diff.inserted.char",
            "background": "hsla(80, 65%, 53%, 0.30)",
            "foreground_adjust": "l(+ 10%)"
        },
    ]
}

/etc/systemd/system/k3s.service:

[Unit]
Description=Lightweight Kubernetes
Documentation=https://k3s.io
After=network-online.target

[Service]
Type=notify
EnvironmentFile=/etc/systemd/system/k3s.service.env
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/k3s \
    server \

KillMode=process
Delegate=yes
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
TimeoutStartSec=0
Restart=always
RestartSec=5s

[Install]
WantedBy=multi-user.target

\Users\user_name.ssh\config (windows dir):

Host *
  StrictHostKeyChecking no
  IdentityFile ~/.ssh/id_rsa
  ControlMaster auto
  ControlPersist 600

PowerCLI: https://code.visualstudio.com/docs/remote/troubleshooting#_enabling-alternate-ssh-authentication-methods:

# Make sure you're running as an Administrator
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
Get-Service ssh-agent

PowerShell/Win32-OpenSSH#1234 (comment):

# as admin
sc.exe create sshd binPath=C:\Windows\System32\OpenSSH\ssh.exe

------------------------------------- GEMRC -------------------------------------

echo $'install: --no-rdoc --no-ri\nupdate: --no-rdoc --no-ri' > ~/.gemrc

install: --no-rdoc --no-ri
update:  --no-rdoc --no-ri

------------------------------------- GEMRC -------------------------------------

------------------------------------- SUBLIME -------------------------------------

Ref: https://www.sublimetext.com/docs/3/linux_repositories.html

wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install sublime-text

NOTE: on debian, launching sublime fails because it's missing dependencies (which sublime fails to mention...)
sudo apt install libglib2.0-0 libx11-6 libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgtk2.0-0

install package control

install packages:

compare sibe-by-side
git
rubocop
sidebarenhancements
sublimelinter
sublimerepl
terminalview
theme-flatland

sublimerepl:

# for pry ruby error - https://github.com/smiler/SublimeREPL/commit/95ffe15382336ef6720502752e71c290055cf7f8

''                                                             ---> require 'pry/input_completer' # line 4
def puts(data="")                                              ---> def print(data="") # line 20
completer = Pry::InputCompleter.build_completion_proc(binding) ---> completer = Pry::InputCompleter.new(binding) # line 38

sublime user settings:

{
	"ignored_packages":
	[
	],
	"ensure_newline_at_eof_on_save": true,
	"font_size": 12,
	"tab_size": 2,
	"translate_tabs_to_spaces": true,
	"trim_trailing_white_space_on_save": false,
	"color_scheme": "Monokai.sublime-color-scheme",
}

NOTE: edit the color scheme after

sublime key bindings

[
  { "keys": ["super+shift+r"], "command": "goto_definition" }
]

------------------------------------- SUBLIME -------------------------------------

------------------------------------- AUTOHOTKEY -------------------------------------

Part of .ahk file when created:

#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.

Added

CapsLock::Ctrl
!-::SendInput {PgUp}
!=::SendInput {PgDn}
!;::SendInput {Home}
!'::SendInput {End}
![::SendInput !{Left}
!]::SendInput !{Right}
!+;::SendInput +{Home}
!+'::SendInput +{End}
!+[::SendInput ^+{Tab}
!+]::SendInput ^{Tab}

~- Create shortcut in %appdata%\Microsoft\Windows\Start Menu\Programs\Startup -> C:\Users\<user>\nav.ahk

  • C:\ProgramData\chocolatey\bin\AutoHotkey.exe C:\Users\<user>\nav.ahk --> Properties > Shortcut > Advanced > Run as Administrator~
  • search Task Scheduler
  • create task
  • General > name: NavKeys (arbitrary) [x] Run with highest privileges
  • Triggers > new > {At log on}
  • Actions > new > {Start a program} Program/script: C:\ProgramData\chocolatey\bin\AutoHotkey.exe Add arguments (optional): C:\Users\ralph\nav.ahk Start in (optional): C:\Users\ralph

------------------------------------- AUTOHOTKEY -------------------------------------

------------------------------------- RAILS -------------------------------------

#delete accidentally added gem docs
rm -r "$(gem env gemdir)"/doc/*

#pry rails console ~/.irbrc

# ruby 1.8.7 compatible
require 'rubygems'
require 'irb/completion'

# awesome print
begin
  require 'awesome_print'
  AwesomePrint.irb!
rescue LoadError => err
  warn "Couldn't load awesome_print: #{err}"
end

# irb history
IRB.conf[:EVAL_HISTORY] = 1000
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = File::expand_path("~/.irbhistory")

# load .railsrc in rails environments
railsrc_path = File.expand_path('~/.irbrc_rails')
if ( ENV['RAILS_ENV'] || defined? Rails ) && File.exist?( railsrc_path )
  begin
    load railsrc_path
  rescue Exception
    warn "Could not load: #{ railsrc_path } because of #{$!.message}"
  end
end

class Object
  def interesting_methods
    case self.class
    when Class
      self.public_methods.sort - Object.public_methods
    when Module
      self.public_methods.sort - Module.public_methods
    else
      self.public_methods.sort - Object.new.public_methods
    end
  end
end

module Kernel
  def require_relative(file)
    $:.unshift Dir.pwd
    require file
  end

  def guid(s)
    s.scan(/[a-f0-9-]{36}/).first
  end
end

#I no longer use this.... ~/.pryrc

begin
  require 'hirb'
rescue LoadError
  # Missing goodies, bummer
end

if defined? Hirb
  # Slightly dirty hack to fully support in-session Hirb.disable/enable toggling
  Hirb::View.instance_eval do
    def enable_output_method
      @output_method = true
      @old_print = Pry.config.print
      Pry.config.print = proc do |*args|
        Hirb::View.view_or_page_output(args[1]) || @old_print.call(*args)
      end
    end

    def disable_output_method
      Pry.config.print = @old_print
      @output_method = nil
    end
  end

  Hirb.enable
end
gems:
  'awesome_print', require: 'ap'
  'bullet'
  'rubocop'
  'paper_trail'
  'letter_opener'
  'sidekiq'
  'rspec_api_documentation'
  'intercom'
  'active_model_serializers', '~> 0.10.0.rc2'
  'kaminari'

  'elasticsearch-model', github: 'elastic/elasticsearch-rails'
  'elasticsearch-rails', github: 'elastic/elasticsearch-rails'
  'algoliasearch-rails'
  'attr_encrypted', "~> 2.0.0"

------------------------------------- RAILS -------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment