Skip to content

Instantly share code, notes, and snippets.

View ufarooq's full-sized avatar

Umar Farooq ufarooq

View GitHub Profile
@ufarooq
ufarooq / readme.md
Created May 22, 2024 14:57
Gemini Code Assist

Generate code with prompts

This document shows you how to use Gemini Code Assist in Project IDX to generate code with the example prompt # Function to perform binary search on a list of numbers inside a Python file. You can also select a part of your code and then prompt Gemini Code Assist for help through the chat feature, and receive and accept or reject code suggestions while you code.

Prompt Gemini Code Assist in a code file

Create a new or use an existing code file. If you're using the Python (Flask) sample, you can do this in your main.py file: navigate to Explorer > src > and open the main.py file.

In your code file, on a new line, enter # Function to perform binary search on a list of numbers, and then press Enter (for Windows and Linux) or Return (for macOS).

Next to your prompt text in the Python file, Gemini Code Assist generates the code in the form of ghost text.

*** javap -p MainTestActivity.class"
Compiled from "MainTestActivity.java"
public class com.example.testapp.MainTestActivity extends android.app.Activity {
private java.lang.String name;
private android.widget.TextView nameTextView;
private android.widget.Button mButton;
private com.example.testapp.ObjectA a;
private com.example.testapp.ObjectA b;
private com.example.testapp.ObjectA x;
private com.example.testapp.ObjectA z;
package android.wala.test;
import android.wala.CallGraphSearchUtil;
import android.wala.ExampleUtil;
import com.ibm.wala.cast.ir.ssa.AstIRFactory;
import com.ibm.wala.cast.java.client.impl.ZeroOneContainerCFABuilderFactory;
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
import com.ibm.wala.cast.java.ipa.modref.AstJavaModRef;
import com.ibm.wala.cast.java.ipa.slicer.AstJavaSlicer;
import com.ibm.wala.cast.java.translator.jdt.ecj.ECJClassLoaderFactory;
@ufarooq
ufarooq / Test.c
Created March 4, 2019 23:44
Test cases for Liveness Analysis
void test1(int a, int b, int c, int d, int e, int f) {
a = c + 11;
b = f * e;
while (a < b) {
a = b * c;
d = b;
if (d > c)
b = b + 1;
else
e = d * c;
@ufarooq
ufarooq / SimpleTest.c
Last active February 12, 2019 02:29
Test cases for Value Numbering
void test1(int a, int b, int c, int d, int e, int f, int g) {
c = a + b;
d = c + 5;
e = a + b;
f = e + 5;
g = d + f;
}
void test2(int a, int b, int c, int x, int y) {