Skip to content

Instantly share code, notes, and snippets.

package com.tonal.trainer.anvilcompilers
import com.google.auto.service.AutoService
import com.squareup.anvil.annotations.ContributesTo
import com.squareup.anvil.compiler.api.AnvilContext
import com.squareup.anvil.compiler.api.CodeGenerator
import com.squareup.anvil.compiler.api.GeneratedFile
import com.squareup.anvil.compiler.api.createGeneratedFile
import com.squareup.anvil.compiler.internal.asClassName
import com.squareup.anvil.compiler.internal.buildFile
@vshivam
vshivam / AlphaPropertySerializer.kt
Last active November 15, 2022 02:08
When a mobile client interacts with backend, api contracts are subject to change heavily during the development phase. With this custom serializer we can ensure that it is "okay" to break contracts. Properties can be added, removed and updated without the fear of "older clients" breaking.
class AlphaPropertySerializer<T>(
private val valueSerializer: KSerializer<T>
) : KSerializer<AlphaProperty<T>> {
override val descriptor: SerialDescriptor = valueSerializer.descriptor
override fun deserialize(decoder: Decoder): AlphaProperty<T> {
decoder as JsonDecoder
val jsonElement: JsonElement = decoder.decodeJsonElement()

Keybase proof

I hereby claim:

  • I am vshivam on github.
  • I am vshivam (https://keybase.io/vshivam) on keybase.
  • I have a public key whose fingerprint is 2282 43DA A154 4883 584E 64E6 B230 4743 671C AA53

To claim this, I am signing this object:

@vshivam
vshivam / hacker-cup-2016-r1.java
Last active June 6, 2016 10:11
Facebook Hacker Cup 2016 Round 1
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Main {
// https://gist.githubusercontent.com/maksverver/89776622d809e3f8e69e/raw/59d6819bf90f527f8e3597abda0a905dd4a2743a/A.txt
public static void main(String[] args) {
File input = new File("/home/shivam/Desktop/work/code/algo/src/input.txt");
// ==UserScript==
// @name Spoiler Killer
// @include http://*.facebook.com/*
// @include https://*.facebook.com/*
// @require http://code.jquery.com/jquery-1.7.1.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant none
// @version 1
// @namespace http://shivamverma.info
// @description Blacken facebook posts possibly containing Game of Thrones spoilers.
@vshivam
vshivam / no-spoiler.user.js
Last active May 25, 2016 12:14
Greasemonkey script to hide/mark spoilers on your Facebook homepage.
// ==UserScript==
// @name Spoiler Killer
// @include http://*.facebook.com/*
// @include https://*.facebook.com/*
// @require http://code.jquery.com/jquery-1.7.1.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant none
// @version 1
// @namespace http://shivamverma.info
// @description Blacken/Completely hide facebook status updates with Game of Thrones spoilers
function unfollow(){
var tag = $('a[action_click="UserUnfollow"]')[0];
console.log(tag);
if(typeof tag !== 'undefined') {
tag.click();
} else {
clearInterval(counter);
}
}
# Built application files
/*/build/
# Crashlytics configuations
com_crashlytics_export_strings.xml
# Local configuration file (sdk path, etc)
local.properties
# Gradle generated files
@vshivam
vshivam / dnssdServer.py
Created February 2, 2015 15:57
Simple HttpServer which serves DNS-SD Service info
"""
Serves files out of its current directory.
Doesn't handle POST requests.
"""
import SocketServer
import SimpleHTTPServer
from zeroconf import *
import socket
import time
/*!
* Dynamically changing favicons with JavaScript
* Works in all A-grade browsers except Safari and Internet Explorer
* Demo: http://mathiasbynens.be/demo/dynamic-favicons
*/
// HTML5™, baby! http://mathiasbynens.be/notes/document-head
document.head || (document.head = document.getElementsByTagName('head')[0]);
function changeFavicon(src) {