Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

GVSharma gvsharma

🎯
Focusing
View GitHub Profile
View spring-boot-cheatsheet.java
// Enable component-scanning and auto-configuration with @SpringBootApplication Annotation
// It combines @Configuration + @ComponentScan + @EnableAutoConfiguration
@SpringBootApplication
public class FooApplication {
public static void main(String[] args) {
// Bootstrap the application
SpringApplication.run(FooApplication.class, args);
}
}
View Java Collections Complexity cheatsheet
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@gvsharma
gvsharma / System Design.md
Created Jul 2, 2019 — forked from vasanthk/System Design.md
System Design Cheatsheet
View System Design.md

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@gvsharma
gvsharma / CustomFragmentsPresenter.cs
Created Oct 6, 2017 — forked from martijn00/CustomFragmentsPresenter.cs
Custom fragment handling in MvvmCross and Xamarin
View CustomFragmentsPresenter.cs
public class CustomFragmentsPresenter : MvxFragmentsPresenter
{
public interface IMvxFragmentHostEx : IMvxFragmentHost
{
void Close(IMvxViewModel viewModel);
void ChangePresentation (MvxPresentationHint hint);
}
private IMvxNavigationSerializer _serializer;
View MonkeysPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Monkeys.Views.MonkeysPage"
xmlns:local="clr-namespace:Monkeys.Views;assembly=Monkeys"
Title="Monkeys">
<ListView x:Name="list"
ItemsSource="{Binding MonkeysGrouped}"
ItemTapped="OnItemSelected"
IsGroupingEnabled="True"
View gist:da6afe9f1accbf91711805191d4d23b1
using System;
using System.Linq;
using Xamarin.Forms;
using System.Collections.Generic;
using System.ComponentModel;
namespace SampleApp
{
// Inherit from this page to get a multi-select option in XF
public class SelectMultipleBasePage<T> : ContentPage
View gist:57d0668a8826ae6fe58ced5eb1e843cd
public class CustomAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
//our items
List<Generic> items = new Arraylist<>();
//headers
List<View> headers = new ArrayList<>();
//footers
List<View> footers = new ArrayList<>();
public static final int TYPE_HEADER = 111;
public static final int TYPE_FOOTER = 222;
View gist:b46d69a278060e64b7df173e6e50e333
public class BlurUtil {
public static Bitmap blur(Context context, Bitmap sentBitmap, int radius) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
final RenderScript rs = RenderScript.create(context);
final Allocation input = Allocation.createFromBitmap(rs, sentBitmap, Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT);
View SimpleXmlRequest.java
import java.io.UnsupportedEncodingException;
import java.util.Map;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
@gvsharma
gvsharma / getTmepFile() method
Created Jun 5, 2014
getting an image from camera or gallery and set it as
View getTmepFile() method
private Uri getTempFile(){
File root = new File(Environment.getExternalStorageDirectory(), "fashion_swap");
if (!root.exists()){
root.mkdirs();
}
String filename=""+System.currentTimeMillis();
File file = new File(root,filename+".jpeg" );
Uri muri = Uri.fromFile(file);
selectedImagePath = muri.getPath();
Log.v("take picture path",selectedImagePath);