Skip to content

Instantly share code, notes, and snippets.

View magicus's full-sized avatar
Java

Magnus Ihse Bursie magicus

Java
  • Oracle
  • Stockholm, Sweden
  • 11:35 (UTC +02:00)
View GitHub Profile
@l-Luna
l-Luna / collections.md
Last active January 24, 2022 16:14
Collection Literals

Collection Literals

How far this goes

This proposal is not intended to add support for general-purpose custom initializer syntax for any kind of object, nor is it intended to allow for custom DSLs in Java. This is for simple shorthand:

Map<String, Object> values = { "a": "alpha", "b": "beta", null: this };

var list = ArrayList<String> { "a", "b", "c" };

Set checked = HashSet&lt;&gt; { NORTH, SOUTH, NORTHWEST, };
"""
Custom component to interface with vattenfall
"""
import logging
from datetime import datetime, timedelta
import pytz
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
@dardo82
dardo82 / safari-favicons.sh
Last active February 16, 2024 02:40
Fix Safari FavIcons
#!/bin/zsh
# Fix Safari Favorites Icons
CS="cache_settings"; TIC="Touch Icons Cache"; DIR="$HOME/Library/Safari/$TIC/Images"
DB="$DIR/../${${TIC// }%%s*}${${(C)CS}//_}.db"; SQL=$(sqlite3 "$DB" "SELECT host FROM $CS")
sqlite3 "$DB" "UPDATE $CS SET ${${${(L)TIC// /_}#*_}//s/_is_in}=1, download_status_flags=1"
for png in "$1"/*.png; do URL="$(plutil -convert xml1 -o - "$DIR/../../Bookmarks.plist" | \
awk -F '[</>]' -v name="${${png##*/}%%.*}" '$3~name{getline;getline;getline;print $5}')"; \
cp -f -v "$png" "$DIR/${(U)$(md5 -q -s $URL)}.png"; done; chflags -v uappnd $DIR $DB*
@suberb
suberb / elementaryos.md
Last active December 25, 2023 19:14
elementaryOS | Things To Do After Installing Elementary OS Loki [Best OS For Switching From Windows & Mac]

FIRST THING FIRST


  • Update OS
sudo apt-get update && sudo apt-get upgrade

Introduction

Sometimes you may want to use a DNS server for specific domain requests and another DNS server for all other requests. This is helpful, for instance, when connected to a VPN. For hosts behind that VPN you want to use the VPN's DNS server but all other hosts you want to use Google's public DNS. This is called "DNS splitting."

Here, we run dnsmasq as a background service on macOS. The dnsmasq configuration described below implements DNS splitting.

Install

brew install dnsmasq
@justincjahn
justincjahn / README.md
Last active January 16, 2024 20:15
Minecraft server(s) using systemd and screen.

Install

# Install dependencies
sudo yum install -y java-1.8.0-openjdk screen

# Create a new unprivileged user for minecraft
useradd -r -m -d /opt/minecraft minecraft

# Create the directory that will house our minecraft instances

sudo su --shell /bin/bash minecraft

Set rz and sz on Mac

There are a mess of troubles in sending and receiving files from my macbook to dev server, since I had no permission to excute command scp on dev server. Here is a lightweight, quick, and convenience tools which related with ssh, called lrzsz. lrzsz is a unix communication package providing the XMODEM, YMODEM, ZMODEM file transefer protocol which usually has been already installed in most of servers.

Prerequisites

  • iTerm2 is necessary. [Here][] is the official website.
@dannysperry
dannysperry / initialize_and_connect_methods
Last active December 10, 2023 09:54
PPPP_Read debugging
read_size = FFI::MemoryPointer.new(:int32, 1)
read_size.write_int32(4)
p2p_buffer_size = 128 * 1024
input_buffer = FFI::MemoryPointer.new(:char, p2p_buffer_size, true)
some_obj = SandBox.new.authenticate read_size, input_buffer, 100000
class SandBox
def authenticate(read_size, input_buffer, timeout=100000)
@yamaya
yamaya / xcode-clang-vers
Last active June 21, 2024 08:25
Xcode clang version record
# Xcode 4.3.3
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
# Xcode 4.3.2
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix