Skip to content

Instantly share code, notes, and snippets.

@dhh
dhh / linux-setup.sh
Last active May 19, 2024 09:10
linux-setup.sh
# CLI
sudo apt update -y
sudo apt install -y \
git curl btop \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
libssl-dev libreadline-dev zlib1g-dev libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev libjemalloc2 \
libvips imagemagick libmagickwand-dev mupdf mupdf-tools \
redis-tools sqlite3 libsqlite3-0 libmysqlclient-dev \
rbenv apache2-utils
@greyltc
greyltc / launch-GRD.sh
Last active May 19, 2024 09:10
configures then activates gnome-remote-desktop from the command line
#!/usr/bin/env bash
# run this on the remote terminal machine, as auser with sudo powers, probably through a remote ssh shell
# this will overwrite all the settings it touches
# the name of the user to run these commands as
TARGET_USER=jane
# we need an inlocked desktop session. we can either start a new autologin one or unlock an existing one
@jerblack
jerblack / Elevate when needed in Go.md
Last active May 19, 2024 09:08
Relaunch Windows Golang program with UAC elevation when admin rights needed.

I'm buiding a command line tool in Go that has an option to install itself as a service on Windows, which it needs admin rights for. I wanted to be able to have it reliably detect if it was running as admin already and if not, relaunch itself as admin. When the user runs the tool with the specific switch to trigger this functionality (-install or -uninstall in my case) they are prompted by UAC (User Account Control) to run the program as admin, which allows the tool to relaunch itself with the necessary rights.

To detect if I was admin, I tried the method described here first:
https://coolaj86.com/articles/golang-and-windows-and-admins-oh-my/
This wasn't accurately detecting that I was elevated, and was reporting that I was not elevated even when running the tool in CMD prompt started with "Run as Administrator" so I needed a more reliable method.

I didn't want to try writing to an Admin protected area of the filesystem or registry because Windows has the ability to transparently virtualize those writes

@vishal2376
vishal2376 / Place.kt
Last active May 19, 2024 09:08
Image Reflection with cool animation using Jetpack Compose
data class Place(
val name: String,
val resId: Int
)
@peterbartha
peterbartha / README.md
Last active May 19, 2024 09:05
Convert Rust books to EPUB (incl. The Rust Programming Language)

Convert Rust books to EPUB (incl. The Rust Programming Language)

The following steps work for all the HTML learning materials on the Learn Rust page:

  1. Click on the "Print this book" icon in the top right corner.
  2. "Cancel" print popup.
  3. Press F12.
  4. Copy, paste, and run the contents of ebookFormatPreparation.js into your browser's console.
  5. Save the modified HTML file.
@joshlong
joshlong / UAO.java
Last active May 19, 2024 09:05
this does the same thing as my existing unzip-and-open.py, but in less code and faster, with a compiler to help me.
// I'd suggest you create an alias somewhere:
// alias uao=java --enable-preview --source 21 $HOME/bin/UAO.java
// RUN: uao $HOME/Downloads/demo.zip
import java.io.*;
import java.util.function.*;
import java.util.* ;
void main(String[] args) throws Exception {
var zipFile = new File(args[0]);
@marians
marians / Chromium Linux.md
Last active May 19, 2024 09:03
How to install CA certificates and PKCS12 key bundles on different platforms

We install certutil and pk12util if necessary:

sudo apt install libnss3-tools

On Linux, Chromium uses the NSS Shared DB. Check if you have the ~/.pki/nssdb directory:

ls $HOME/.pki/nssdb
import ReactSelect from 'react-select'
export const REACT_SELECT_CUSTOM_STYLES = {
control: (provided) => ({
...provided,
fontSize: '0.875rem',
lineHeight: '1.25rem'
}),
valueContainer: (provided) => ({
...provided,
@CMingTseng
CMingTseng / tick_locs.py
Created August 17, 2019 14:00 — forked from virus-warnning/ticks_by_location.py
分點進出取資料研究
import os
import re
import requests
import sys
import json
from bs4 import BeautifulSoup
session = requests.Session()
resp = session.get('https://bsr.twse.com.tw/bshtm/bsMenu.aspx')
if resp.status_code == 200:
@mengwangk
mengwangk / java.lua
Last active May 19, 2024 08:49
Neovim PDE - Java
if not require("config").pde.java then
return {}
end
local function get_jdtls()
local mason_registry = require "mason-registry"
local jdtls = mason_registry.get_package "jdtls"
local jdtls_path = jdtls:get_install_path()
local launcher = vim.fn.glob(jdtls_path .. "/plugins/org.eclipse.equinox.launcher_*.jar")
local SYSTEM = "linux"