Skip to content

Instantly share code, notes, and snippets.

@davestewart
davestewart / README.md
Last active April 8, 2024 11:00
Decompile JavaScript from source maps

Decompile JavaScript from source maps

Overview

Modern JavaScript build tools compile entire folder structures of JavaScript code into single, minified files that are near-impossible to read, but can also include source maps which can be used to display the original code in tools such as the Chrome DevTools Sources panel.

These source maps can be processed to extract mainly meaningful code and file structures, by installing a package calling Shuji and running a simple bash command.

Generally, production builds shouldn't include source maps, but if you do manage to lose your source files, or for some (obviously, ethical!) reason need to view the original files, and you happen to have / find the source maps, you're good to go.

@andywer
andywer / Monorepo Setup.md
Last active April 8, 2022 03:50
Monorepo Setup

Overall Approach

This document is a short description of the monorepo setup that I came up for a few different smaller projects in the last 8 months or so.

Directory structure

/
  services/
 product/
@julianfalcionelli
julianfalcionelli / RxErrorHandlingCallAdapterFactory.java
Last active June 21, 2022 08:55
Rx Error Handling for Retrofit2
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import io.reactivex.Completable;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.Single;
import io.reactivex.SingleSource;
import io.reactivex.annotations.NonNull;
@cbeyls
cbeyls / RecyclerViewCursorAdapter.java
Last active April 19, 2018 20:24
Simplified CursorAdapter designed for RecyclerView
package be.digitalia.common.adapters;
import android.database.Cursor;
import android.support.v7.widget.RecyclerView;
/**
* Simplified CursorAdapter designed for RecyclerView.
*
* @author Christophe Beyls
*/
@jgilfelt
jgilfelt / CurlLoggingInterceptor.java
Created January 9, 2016 15:34
An OkHttp interceptor that logs requests as curl shell commands
/*
* Copyright (C) 2016 Jeff Gilfelt.
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
@pulkitsinghal
pulkitsinghal / seller-model.js
Last active March 4, 2017 15:44
How to create an AccessToken in LoopBack for a user
/** A quick github search for sample code:
* > https://github.com/search?utf8=%E2%9C%93&q=-1+AccessToken.create+path%3A%2Fcommon%2Fmodels&type=Code&ref=searchresults
* Yields two similar result:
* > https://github.com/patriciamolina/test/blob/90a8829728e4a404109e1eafa0a1075687042792/common/models/customer.js#L421
* > https://github.com/stormpath/loopback-stormpath/blob/e1cb4d98eacfe36ade2d58e1a48e6cfd590308ff/common/models/stormpath-user.js#L458
*/
module.exports = function(SellerModel) {
SellerModel.observe('after save', function(ctx, next) {
console.log('`after save` supports isNewInstance?', ctx.isNewInstance !== undefined);
@imminent
imminent / Api.java
Created October 15, 2015 16:16
Handling multiple API subdomains with Retrofit 2.0
package com.example.api;
import java.util.Map;
import retrofit.Call;
import retrofit.http.Body;
import retrofit.http.GET;
import retrofit.http.POST;
public interface Api {
@harshil93
harshil93 / SampleModel.js
Created June 8, 2015 07:11
Retrieving / Getting the current user id in a remote method in strongloop's loopback framework.
var loopback = require('loopback');
module.exports = function(SampleModel) {
// Returns null if the access token is not valid
function getCurrentUserId() {
var ctx = loopback.getCurrentContext();
var accessToken = ctx && ctx.get('accessToken');
var userId = accessToken && accessToken.userId;
return userId;
@alex-shpak
alex-shpak / Interceptor.java
Last active June 14, 2024 02:40
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON
@tsuharesu
tsuharesu / AddCookiesInterceptor.java
Last active June 8, 2024 07:30
Handle Cookies easily with Retrofit/OkHttp
/**
* This interceptor put all the Cookies in Preferences in the Request.
* Your implementation on how to get the Preferences MAY VARY.
* <p>
* Created by tsuharesu on 4/1/15.
*/
public class AddCookiesInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {