Skip to content

Instantly share code, notes, and snippets.

View danikx's full-sized avatar

Daniyar Kalmurzin danikx

View GitHub Profile
@danikx
danikx / ScrollingActivity.java
Created May 26, 2018 14:57 — forked from iChintanSoni/ScrollingActivity.java
CollapsingToolbarLayout with TabLayout
public class ScrollingActivity extends AppCompatActivity {
private SectionsPagerAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scrolling);
@danikx
danikx / gist:46b00054be062756e019b602eafe9e9c
Created April 9, 2018 08:55
Prevent screen capturing is way for saving your content.
Android SDK have special flag for it.
https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE
Just declare it in your Activity like this:
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
super.onCreate(savedInstanceState);
@danikx
danikx / edit.xml
Created September 5, 2017 11:48
android edittext with icon
<!--https://github.com/lasemcode/android-login-screen/blob/v1.0/app/src/main/res/layout/login_activity.xml-->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="#D81B60"
android:drawableLeft="@drawable/ic_user_24dp"
android:drawablePadding="16dp"
android:drawableTint="@android:color/white"
android:hint="Username"
@danikx
danikx / Helper.java
Last active September 5, 2017 11:43
android listen gps status
final LocationManager lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
if (Build.VERSION.SDK_INT >= 24) {
lm.registerGnssStatusCallback(new GnssStatus.Callback() {
@Override public void onStarted() {
super.onStarted();
Log.d(TAG, "gps started");
updateGpsView();
}
});
} else {
@danikx
danikx / Helper.java
Last active September 5, 2017 10:25
android check gps enabled (method 2)
public static boolean isGpsEnabled(){
LocationManager lm = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
boolean gps_enabled = false;
boolean network_enabled = false;
try {
gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
} catch(Exception ex) {}
@danikx
danikx / Helper.java
Created September 5, 2017 10:23
android isLocationEnabled
public static boolean isLocationEnabled(Context context) {
int locationMode = 0;
String locationProviders;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
try {
locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);
} catch (SettingNotFoundException e) {
e.printStackTrace();
Edit /etc/config/network. Under “WAN” section, set the configuration with:
config 'interface' 'wan'
option 'ifname' 'eth0.2'
option 'proto' 'pppoe'
option 'username' 'your-own-username'
option 'password' 'your-own-password'
option 'defaultroute' '1'
option 'peerdns' '1'
Force a re-dial
#!/bin/bash
# atlassian-heap-dump.sh - dump a heap using GDB for a crashed application
# Accepts a single argument: the PID of the JVM
# Author: James Gray ([email protected])
# Copyright Atlassian P/L
# License: MIT
# Are we root?
if [ $UID -ne 0 ]; then
#!/bin/sh
# Oneliner by @Coornail, modifications by @ErikBjare
watch -n1 -d "curl -s https://btc-e.com/api/2/btc_usd/ticker | json_pp | tail --line=+2 | head --line=12"
#!/bin/sh
# Requires jq
# Remember to chmod +x!
#
# Add the following cron-job (using "crontab -e") to run at hourly intervals:
# 0 * * * * export DISPLAY=:0.0 && /bin/bash <SCRIPT_PATH_GOES_HERE> > /dev/null 2>&1
# Change <SCRIPT_PATH_GOES_HERE> to the appropriate name
BTCE_PRICE="$(curl -s https://btc-e.com/api/2/btc_usd/ticker | jq '.ticker.last')"