Skip to content

Instantly share code, notes, and snippets.

@JakeWharton
JakeWharton / AspectRatioImageView.java
Created June 2, 2012 02:14
ImageView that respects an aspect ratio applied to a specific measurement.
// Copyright 2012 Square, Inc.
package com.squareup.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;
/** Maintains an aspect ratio based on either width or height. Disabled by default. */
public class AspectRatioImageView extends ImageView {
@JIghtuse
JIghtuse / echo_server.cxx
Last active July 23, 2023 09:06
echo server (select, C++)
#include <array>
#include <cassert>
#include <iostream>
#include <set>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
import android.graphics.Bitmap;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import java.util.Arrays;
/**
* This is copied from https://stackoverflow.com/a/10028267/3050249
* and optimized for less memory consumption & better locality, and creates less GC pressure.
@lapastillaroja
lapastillaroja / DividerItemDecoration.java
Last active November 17, 2023 23:06 — forked from akmalxxx/DividerItemDecoration.java
DividerItemDecoration. RecyclerView.ItemDecoration simple implementation
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
/* VT100 terminal reset (<ESC>c) */
console.log('\033c');
/* numbers comparations */
> '2' == 2
true
> '2' === 2

1. Store api keys in a xml file

Put xml file "api_keys.xml" in the directory "res/value/".

api_keys.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="THE_MOVIE_DB_API_TOKEN">XXXXX</string>
</resources>
@bharath2020
bharath2020 / Download 'data' from Android without roooting
Last active January 25, 2024 21:13
Download manifest from Android APK
//download data.ab (encrypted) and DONOT GIVE ANY PASSWORD when prompted
adb backup -f ~/data.ab -noapk app.package.name
//decrypt and extract the data.ab [this worked most of the time except for few instances ]
//this will output all the contents of app into 'apps' directory
dd if=data.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" | tar -xvf -
//SOURCE: http://blog.shvetsov.com/2013/02/access-android-app-data-without-root.html
@derme302
derme302 / GoogleMap.cs
Last active January 31, 2024 07:38
Load a Google Map into Unity3D
/*
* Based on the Google Maps for Unity Asset
* https://www.assetstore.unity3d.com/en/#!/content/3573
* However the relience on UniWeb has been removed
*
*
Getting Started
---------------
1. Assign the GoogleMap component to your game object.
@marty-wang
marty-wang / gist:5a71e9d0a6a2c6d6263c
Last active February 13, 2024 07:34
Compile and deploy React Native Android app of Release version to device.
Disclaimer: The instructions are the collective efforts from a few places online.
Nothing here is my original. But I want to put them together in one place to save people from spending the same time as I did.
First off, bundle.
==================
1. cd to the project directory
2. Start the react-native packager if not started
3. Download the bundle to the asset folder:
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
@arturlector
arturlector / ios-questions-interview.md
Last active February 25, 2024 18:44
Вопросы на собеседование iOS разработчика.

Вопросы на собеседование iOS разработчика (дополненное издание):

General:

  • Что такое полиморфизм?

  • Что такое *инкапсуляция? Что такое *нарушение инкапсуляции?

  • Чем абстрактный класс отличается от интерфейса?

  • Расскажите о паттерне MVC. Чем отличается пассивная модель от активной?