Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""xml2json.py Convert XML to JSON
Relies on ElementTree for the XML parsing. This is based on
pesterfish.py but uses a different XML->JSON mapping.
The XML->JSON mapping is described at
http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html

Sed - An Introduction and Tutorial by Bruce Barnett

How to use sed, a special editor for modifying files automatically. If you want to write a program to make changes in a file, sed is the tool to use.

There are a few programs that are the real workhorse in the UNIX toolbox. These programs are simple to use for simple applications, yet have a rich set of commands for performing complex actions. Don't let the complex potential of

@eloylp
eloylp / Fedora35Hibernation.md
Last active April 25, 2024 07:40
Fedora 35 hibernation with swapfile, only for hibernation and resume

Fedora35 hibernation

This guide helps to configure the hibernation on a default Fedora35 (also worked fine in previous Fedora34) installation by using a swap file. The Fedora35 installation comes with btrfs as default filesystem. Also, it comes with a zram swap device:

$ swapon
NAME       TYPE      SIZE USED PRIO
/dev/zram0 partition   8G   0B  100
@jagrosh
jagrosh / Github Webhook Tutorial.md
Last active April 25, 2024 07:39
Simple Github -> Discord webhook

Step 1 - Make a Discord Webhook

  1. Find the Discord channel in which you would like to send commits and other updates

  2. In the settings for that channel, find the Webhooks option and create a new webhook. Note: Do NOT give this URL out to the public. Anyone or service can post messages to this channel, without even needing to be in the server. Keep it safe! WebhookDiscord

Step 2 - Set up the webhook on Github

  1. Navigate to your repository on Github, and open the Settings Settings
@EugeneTheDev
EugeneTheDev / DotsLoaders.kt
Created March 18, 2021 23:15
Dots loading animations with Jetpack Compose
import androidx.compose.animation.core.*
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@shaypal5
shaypal5 / confusion_matrix_pretty_print.py
Last active April 25, 2024 07:37
Pretty print a confusion matrix with seaborn
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
def print_confusion_matrix(confusion_matrix, class_names, figsize = (10,7), fontsize=14):
"""Prints a confusion matrix, as returned by sklearn.metrics.confusion_matrix, as a heatmap.
Note that due to returning the created figure object, when this funciton is called in a
notebook the figure willl be printed twice. To prevent this, either append ; to your
function call, or modify the function by commenting out the return expression.
@TWithers
TWithers / GooglePlacesAutocomplete.html
Last active April 25, 2024 07:34
AlpineJS implementation of Google Places Autocomplete
<div x-data="googlePlacesAutocomplete" class="grid grid-cols-3 gap-2">
<input type="text" x-model="address.address1" x-ref="googleAutocomplete" autocomplete="chrome-off" class="col-span-3 sm:col-span-2 order-1" placeholder="Add&#8204;ress">
<input type="text" x-model="address.address2" placeholder="Apt/Ste" class="col-span-3 sm:col-span-1 order-2">
<input type="text" x-model="address.city" placeholder="Ci&#8204;ty" class="col-span-1" x-bind:class="`order-${order.locality}`">
<select x-model="address.state" placeholder="St‌ate" class="col-span-1 order-4" x-show="isUSA">
<option value="">State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>

Coredump contains stack information as well. If you can use this stack information along with the EBP and EIP register values in the coredump file, you can print the stack trace. I had written a program to do this. You can find the program in the following link.

https://gist.github.com/root42/c979b037f85dc4b2be1f3735afedeb1d

Usage: Compile the above program and give the corefile when you execute it.

   $corestrace core

If you want symbols also to be printed, you do like this: Let's assume the program that generated the core is 'test'.

@xyauhideto
xyauhideto / Weibo_Huati_Check-in.user.js
Last active April 25, 2024 07:33
Weibo Huati Check-in
// ==UserScript==
// @name Weibo Huati Check-in
// @description 超级话题集中签到
// @namespace https://greasyfork.org/users/10290
// @version 0.4.2018053114
// @author xyau
// @match http*://*.weibo.com/*
// @match http*://weibo.com/*
// @icon https://n.sinaimg.cn/photo/5b5e52aa/20160628/supertopic_top_area_big_icon_default.png
// @grant GM_getValue
@Quentin18
Quentin18 / train_test_split.py
Created March 16, 2022 17:26
Split dataset function for PyTorch
from typing import Optional, Tuple
import torch
from torch.utils.data import Dataset, random_split
def train_test_split(
dataset: Dataset,
test_ratio: float,
seed: Optional[int] = None,