This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
network={ | |
ssid="eduroam" | |
scan_ssid=1 | |
key_mgmt=WPA-EAP | |
eap=TTLS | |
#anonymous_identity="anonymous@ox.ac.uk" | |
#ca_cert="/etc/ssl/certs/AddTrust_External_Root.pem" | |
phase2="auth=MSCHAPV2" | |
identity="<email>" | |
password="<pwd>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# Copyright 2015 Google Inc. All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Compute the Giacenza Media Annua (GMA) of a Revolut account, required by the Italian INPS. | |
# Dependencies: awk, GNU date, getopts, xargs | |
# Computation method: https://bit.ly/3avDLu3 | |
# Thread on Revolut forum: https://bit.ly/3511e5h | |
# Assumptions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
An improvement of the Disjoint-Set Forest is to control tree heights storing in each node | |
its rank, which is an upper bound for its height. When a node is initialized, its rank is | |
set to zero. To merge trees with roots x and y, first compare their ranks. If the ranks | |
are different, then the larger rank tree becomes the parent, and the ranks of x and y do | |
not change. If the ranks are the same, then either one can become the parent, but the new | |
parent's rank is incremented by one. While the rank of a node is clearly related to its | |
height, storing ranks is more efficient than storing heights. The height of a node can | |
change during a Find operation, so storing ranks avoids the extra effort of keeping the | |
height correct. This method ensures that trees do not become too deep. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Source: https://bitbucket.org/seregaxvm/awesome-wm-configs/src/master/get_secret.lua | |
local Gio = require("lgi").Gio | |
local GLib = require("lgi").GLib | |
local function get_secret(attrs) | |
local bus = Gio.bus_get_sync(Gio.BusType.SESSION, nil) | |
local name = "org.freedesktop.secrets" | |
local object = "/org/freedesktop/secrets" | |
local interface = "org.freedesktop.Secret.Service" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://leetcode.com/problems/longest-palindromic-substring | |
class Solution { | |
public: | |
string longestPalindrome(const string &s) { // Manacher's algorithm, O(n) time | |
if (s.size() <= 1) return s; | |
// insert a bogus char between chars, including outer boundaries | |
string t = "|"; | |
for (auto ch : s) t += ch, t += "|"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <math.h> | |
#include <boost/dynamic_bitset.hpp> | |
void print_subsets(const std::string &str) { | |
std::cout << "[empty string]\n"; | |
const int n = str.size(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <stack> | |
struct TreeNode { | |
int val; | |
TreeNode* left; | |
TreeNode* right; | |
TreeNode() : val(0), left(nullptr), right(nullptr) {} | |
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://leetcode.com/problems/implement-strstr | |
class Solution { | |
public: | |
// Brute force, O((m - n) * n) worst and average case, O(n) best case | |
int strStrNaive(const string& text, const string& pattern) { | |
int m = text.size(), n = pattern.size(); | |
// be consistent with C/C++ strstr() and Java indexOf() | |
if (!n) return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://leetcode.com/problems/merge-k-sorted-lists | |
/* | |
* O(N log k) time and O(1) space, where N is the total number of nodes. | |
* | |
* # Explanation of the time complexity | |
* | |
* Let n be an upper bound on the number of nodes of each list. | |
* | |
* We iteratively merge pairs of lists as follows: |
NewerOlder