Skip to content

Instantly share code, notes, and snippets.

View sourabhv's full-sized avatar

Sourabh Verma sourabhv

View GitHub Profile
@sourabhv
sourabhv / wsl-vpn-net-fix.sh
Created August 18, 2022 22:46
Bash script to fix internet access in WSL2 via powershell when connected to VPN which changes network interface adapter (like Cisco AnyConnect)
#!/bin/bash
# MIT License
# -----------------------------------------------------------------------------
# Copyright 2022 Sourabh Verma
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#!/bin/bash
set -eu
SENTRY_DOWNLOAD_Linux_i686="https://downloads.sentry-cdn.com/sentry-cli/1.37.4/sentry-cli-Linux-i686"
SENTRY_DOWNLOAD_Windows_x86_64="https://downloads.sentry-cdn.com/sentry-cli/1.37.4/sentry-cli-Windows-x86_64.exe"
SENTRY_DOWNLOAD_Darwin_x86_64="https://downloads.sentry-cdn.com/sentry-cli/1.37.4/sentry-cli-Darwin-x86_64"
SENTRY_DOWNLOAD_Linux_x86_64="https://downloads.sentry-cdn.com/sentry-cli/1.37.4/sentry-cli-Linux-x86_64"
SENTRY_DOWNLOAD_Windows_i686="https://downloads.sentry-cdn.com/sentry-cli/1.37.4/sentry-cli-Windows-i686.exe"
VERSION="1.38.0"
PLATFORM=`uname -s`
var markdownIt = require('markdown-it')
function delim_plugin(md) {
// Insert each marker as a separate text token, and add it to delimiter list
//
function tokenize(state, silent) {
var i, scanned, token, len, ch,
start = state.pos,
marker = state.src.charCodeAt(start);

Keybase proof

I hereby claim:

  • I am sourabhv on github.
  • I am sourabhv (https://keybase.io/sourabhv) on keybase.
  • I have a public key ASDcNNUxAtMIPrgb6Vt-gd7PWl61zqV8XUnM06g9gM_H7Qo

To claim this, I am signing this object:

@sourabhv
sourabhv / AddressRepository.java
Last active May 26, 2017 05:37
Repository Design Pattern in Android using RxJava, Retrofit, SQLBrite and SQLDelight Raw
public class AddressRepository implements BaseRepo<Address> {
private final RestApi mRestApi;
private final BriteDatabase mDatabase;
public AddressRepository(RestApi restApi, BriteDatabase database) {
mRestApi = restApi;
mDatabase = database;
}
@sourabhv
sourabhv / SqlBriteExample.java
Last active May 26, 2017 05:32
Repository Design Pattern in Android using RxJava, Retrofit, SQLBrite and SQLDelight Raw
SqlBrite sqlBrite = new SqlBrite.Builder().build();
BriteDatabase database = sqlBrite.wrapDatabaseHelper(openHelper, Schedulers.io());
// Insert transaction
Transaction transaction = database.newTransaction();
Address.InsertRow insertRow = new Address.InsertRow(database.getWritableDatabase());
try {
insertRow.bind(1, "Home", "House No. 42", "Foo Lane", null, "Gurgaon", "India", 123456);
database.executeInsert(Address.TABLE_NAME, insertRow.program);
@sourabhv
sourabhv / Address2.java
Last active May 26, 2017 05:32
Repository Design Pattern in Android using RxJava, Retrofit, SQLBrite and SQLDelight Raw
@AutoValue
public abstract class Address implements AddressModel, Parcelable {
public static final Factory<Address> FACTORY = new Factory<>(AutoValue_Address::new);
public static final Func1<Cursor, Address> MAPPER = FACTORY.selectAllMapper()::map;
public static Builder builder() {
return new AutoValue_Address.Builder();
}
@AutoValue
public abstract class Address implements AddressModel {
public static final Factory<Address> FACTORY = new Factory<>(new AddressModel.Creator<Address>() {
@Override
public Address create(long id, @NonNull String name, @NonNull String line1, @Nullable String line2, @Nullable String landmark, @NonNull String city, @NonNull String country, long pincode) {
return Address.builder()
.id(id)
.name(name)
.line1(line1)
@sourabhv
sourabhv / Address.sq
Last active May 24, 2017 17:04
Repository Design Pattern in Android using RxJava, Retrofit, SQLBrite and SQLDelight
CREATE TABLE address (
id INTEGER NOT NULL,
name TEXT NOT NULL,
line1 TEXT NOT NULL,
line2 TEXT,
landmark TEXT,
city TEXT NOT NULL,
country TEXT NOT NULL,
pincode INTEGER NOT NULL,
PRIMARY KEY(id) ON CONFLICT REPLACE
@sourabhv
sourabhv / BaseRepository.java
Last active May 25, 2017 08:11
Repository Design Pattern in Android using RxJava, Retrofit, SQLBrite and SQLDelight
public interface BaseRepository<T> {
Observable<T> add(T item);
Observable<List<T>> add(List<T> items);
Observable<T> query(long id);
Observable<List<T>> query();
Observable<T> update(T item);
Observable<Integer> remove(T item);
}