Skip to content

Instantly share code, notes, and snippets.

@edwardw
edwardw / readme.md
Last active June 15, 2024 19:27
Android captive portal settings

The android captive portal settings are responsible for the annoying question mark beside the wifi icon. If the device can't connect to the captive portals, the question mark will appear. And at the latest Pixel 8a (android-os 14 I believe), it will also route the traffic through the carrier network which is clearly not desirable.

The settings can be changed by adb (https://gist.github.com/tonyseek/bc5b72197ddb15418c61406061720186):

$ sudo pacman -S android-tools

$ adb shell settings put global captive_portal_https_url <some_server_address>
$ adb shell settings put global captive_portal_http_url <some_server_address>
$ adb shell settings put global captive_portal_fallback_url <some_server_address>
$ adb shell settings put global captive_portal_other_fallback_urls 
@edwardw
edwardw / PasswordManager.purs
Created March 8, 2020 08:06
PureScript Run is fun
-- https://haskell-explained.gitlab.io/blog/posts/2019/07/28/polysemy-is-cool-part-1/
module PasswordManager where
import Prelude
import Data.Map (Map)
import Data.Map as M
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Node.Crypto.Hash (Algorithm(..), base64)
@edwardw
edwardw / adapter.rs
Last active December 29, 2019 15:07
AsyncRead adapter
//# bytes = "0.5"
//# futures = "0.3"
//# tokio = { version = "0.2", features = ["stream", "io-util"] }
//# tokio-util = { version = "0.2", features = ["codec"] }
mod adapter {
use futures::io as fio;
use std::{
pin::Pin,
task::{Context, Poll},
};
@edwardw
edwardw / Cargo.toml
Created December 20, 2019 14:42
Cycle a Rust iterator a given number of times
[package]
name = "cycle_n"
version = "0.1.0"
authors = ["whoever"]
edition = "2018"
[dependencies]
[dev-dependencies]
criterion = "0.3"
@edwardw
edwardw / ClassHierarchy.java
Last active December 21, 2016 02:56
Determine java class hierarchies programmatically
import java.io.File;
import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.*;
import javax.lang.model.element.*;
import javax.tools.*;
import com.sun.source.tree.*;
import com.sun.source.util.*;
@edwardw
edwardw / issue22077.patch
Last active August 29, 2015 14:15
A fix for #22077 on top of #22338
diff --git a/src/librustc_typeck/check/assoc.rs b/src/librustc_typeck/check/assoc.rs
index 2f3bd5d..5a319a6 100644
--- a/src/librustc_typeck/check/assoc.rs
+++ b/src/librustc_typeck/check/assoc.rs
@@ -9,31 +9,35 @@
// except according to those terms.
use middle::infer::InferCtxt;
-use middle::traits::{self, FulfillmentContext, Normalized, MiscObligation,
- SelectionContext, ObligationCause};
@edwardw
edwardw / gist:7587876
Created November 21, 2013 19:20
Boot to Rust in OS X

Booting to Rust by Eric Holk! It is just mind-bogglingly cool. What else can I say? His enhancement to Rust has been landed so it is time for me to try that out, in OS X. The setup of the toolchain could be a little bit challenging.

First and foremost, check out the latest Rust with win64 calling convention contributed by Eric Holk and build it.

Then prepare the cross linker.

$ wget http://ftpmirror.gnu.org/binutils/binutils-2.23.2.tar.gz
$ tar xvzf binutils-2.23.2.tar.gz
$ cd binutils-2.23.2
$ mkdir dist
@edwardw
edwardw / rust_tasks_and_macros.md
Last active December 15, 2015 00:59
Go Concurrency Challenge in Rust

An adaption of Leah Hanson's solution using Rust macros. The original go challenge goes here.

Compiled with Rust 0.5.

use core::task::spawn;
use core::pipes::{stream,Port,Chan,SharedChan};

macro_rules! compute_and_send(
    ($inp:expr, $port:ident) => (
@edwardw
edwardw / gist:5036535
Created February 26, 2013 06:59
Install octave-forge miscellaneous package in homebrew octave

There are some mysterious errors when trying to install miscellaneous package from octave-forge:

error: variable length array of non-POD element type 'Array<octave_idx_type>'

etc. This happens to homebrew-ed octave 3.6.4.

The issue seems to have something to do with clang, the default compiler homebrew uses to install octave. The solution for now is to use gcc instead:

$ export CXX=llvm-g++-4.2 
@edwardw
edwardw / gist:4138639
Created November 24, 2012 06:21
Install numpy/scipy on mountain lion

Scipy Superpack is kind nice, but it seems to be inactive for a while and I want every thing under my complete control. So I went on installing them myself under homebrew-ed python.

Prerequisite

$ brew install python
$ brew install gfortran swig

Scipy/Numpy