Skip to content

Instantly share code, notes, and snippets.

View marc0x71's full-sized avatar
🤪

marc0x71 marc0x71

🤪
View GitHub Profile
@marc0x71
marc0x71 / gist:1195bee72fbfe7058d49
Last active March 7, 2016 07:01
"Could not resolve com.android.support:appcompat-v7:23.2.0"
If you got the following error
$ ./gradlew assemble
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_mockDebugCompile'.
> Could not resolve com.android.support:appcompat-v7:23.2.0.
Required by:
Ordify:app:unspecified
> Could not resolve com.android.support:appcompat-v7:23.2.0.
@marc0x71
marc0x71 / AndroidManifest.xml
Last active March 20, 2016 16:24
Lock and Unlock device during test
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
...
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
...
</manifest>
@marc0x71
marc0x71 / AndroidManifest.xml
Last active March 22, 2016 14:59
Take photo from gallery and camera
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.camera"
android:required="true" />
@marc0x71
marc0x71 / MainActivity.java
Last active March 30, 2021 01:35
BottomSheetDialog example
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openDialog();
}
@marc0x71
marc0x71 / MyDialog.java
Created April 30, 2016 06:00
Set the width of the DialogFragment proportional to 90% of the screen width
@Override
public void onResume() {
// Set the width of the dialog proportional to 90% of the screen width
Window window = getDialog().getWindow();
Point size = new Point();
Display display = window.getWindowManager().getDefaultDisplay();
display.getSize(size);
window.setLayout((int) (size.x * 0.90), WindowManager.LayoutParams.WRAP_CONTENT);
window.setGravity(Gravity.CENTER);
super.onResume();
@marc0x71
marc0x71 / gist:ceec8a59508a4bfa05252687a23efbb7
Created May 5, 2016 14:04
Show the contact in the android contact manager
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactID));
intent.setData(uri);
context.startActivity(intent);
@marc0x71
marc0x71 / values.txt
Created June 6, 2016 10:38
Android screen size values
-- TABLET --
values-sw720dp 10.1” tablet 1280x800 mdpi
values-sw600dp 7.0” tablet 1024x600 mdpi
-- PHONE --
values-sw480dp 5.4” 480x854 mdpi
values-sw480dp 5.1” 480x800 mdpi
values-xhdpi 4.7” 1280x720 xhdpi
values-xhdpi 4.65” 720x1280 xhdpi
values-hdpi 4.0” 480x800 hdpi
@marc0x71
marc0x71 / MainActivity.java
Created June 7, 2016 16:41
VectorDrawable on pre-lollipop
public class MainActivity extends AppCompatActivity {
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
...
}
@marc0x71
marc0x71 / load_gtfs.cql
Last active April 28, 2021 16:42
Load GTFS data into Neo4j
//LOAD CSV script for GFTS data
create constraint on (a:Agency) assert a.id is unique;
create constraint on (r:Route) assert r.id is unique;
create constraint on (t:Trip) assert t.id is unique;
create index on :Trip(service_id);
create constraint on (s:Stop) assert s.id is unique;
create index on :Stoptime(stop_sequence);
create index on :Stop(name);
//add the agency
@marc0x71
marc0x71 / App.java
Created November 1, 2017 19:21
Default Timber app
public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree() {
@Override
protected String createStackElementTag(StackTraceElement element) {