Skip to content

Instantly share code, notes, and snippets.

@c3ph3us
c3ph3us / HandlerLoopOnActivity.java
Created June 22, 2016 12:33
an example of use runnable loop via handler post delayed
/*
* Copyright © 2015-2016. by ceph3us
* All Rights Reserved.
* www.ceph3us.pl
*/
package pl.ceph3us.android.examples;
import android.app.Activity;
import android.os.Bundle;
@c3ph3us
c3ph3us / ParcelableUtil.java
Created July 19, 2016 03:35 — forked from omarmiatello/ParcelableUtil.java
Parcelable to byte array, byte array to parcelable
/**
* Copyright 2013 Omar Miatello - [email protected]
* Based on http://stackoverflow.com/a/18000094/1228545
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@c3ph3us
c3ph3us / ScrollViewWithMaxHeight.java
Created September 20, 2016 13:08 — forked from JMPergar/ScrollViewWithMaxHeight.java
ScrollView that can be configured with max height
public class ScrollViewWithMaxHeight extends ScrollView {
public static int WITHOUT_MAX_HEIGHT_VALUE = -1;
private int maxHeight = WITHOUT_MAX_HEIGHT_VALUE;
public ScrollViewWithMaxHeight(Context context) {
super(context);
}
private ListView mListView;
private MoPubAdAdapter mAdAdapter;
private RequestParameters myRequestParameters;
private static final String MY_AD_UNIT_ID = "myAdUnitId";
@Override
public void onCreate(Bundle savedInstanceState) {
// Set up your adapter as usual.
Adapter myAdapter;
@c3ph3us
c3ph3us / android_replace_in_manifest.gradle
Created January 23, 2017 11:04 — forked from saadfarooq/android_replace_in_manifest.gradle
Gradle function to replace a placeholder string in AndroidManifest.xml with productFlavor package name
replaceInManifest = {variant, fromString, toString ->
def flavor = variant.productFlavors.get(0)
def buildtype = variant.buildType
def manifestFile = "$buildDir/manifests/${flavor.name}/${buildtype.name}/AndroidManifest.xml"
def updatedContent = new File(manifestFile).getText('UTF-8').replaceAll(fromString, toString)
new File(manifestFile).write(updatedContent, 'UTF-8')
}
@c3ph3us
c3ph3us / adb-wrapper.sh
Created April 28, 2017 18:49 — forked from elsnosrap/adb-wrapper.sh
A useful shell script that wraps Android adb commands when multiple devices or emulators are connected. The script will prompt for a device or emulator to run the command against, if it detects multiple devices / emulators.
#!/bin/bash
# This is a wrapper for adb. If there are multiple devices / emulators, this script will prompt for which device to use
# Then it'll pass whatever commands to that specific device or emulator.
# Run adb devices once, in event adb hasn't been started yet
BLAH=$(adb devices)
# Grab the IDs of all the connected devices / emulators
IDS=($(adb devices | sed '1,1d' | sed '$d' | cut -f 1 | sort))
@c3ph3us
c3ph3us / update_mysql_max_conn.sql
Created May 1, 2017 18:19 — forked from lemenkov/update_mysql_max_conn.sql
Increase max_connections in MySQL/MariaDB without restarting mysqld service
# http://www.linux4beginners.info/node/increase-max-connections-mysql-without-restart
select @@max_connections;
set global max_connections = 200;
select @@max_connections;
@c3ph3us
c3ph3us / mysqld
Created June 4, 2017 02:54 — forked from inouetakuya/mysqld
/etc/logrotate.d/mysqld
# cat /etc/logrotate.d/mysqld
# This logname can be set in /etc/my.cnf
# by setting the variable "err-log"
# in the [safe_mysqld] section as follows:
#
# [safe_mysqld]
# err-log=/var/log/mysqld.log
#
# If the root user has a password you have to create a
@c3ph3us
c3ph3us / set-up-l2tp-ipsec-vpn-on-debian.md
Last active October 21, 2017 17:10 — forked from mietek/set-up-l2tp-ipsec-vpn-on-debian.md
Set up L2TP/IPsec VPN on Debian

Set up L2TP/IPsec VPN on Debian

Set up IPsec

Set up networking

@c3ph3us
c3ph3us / scp-ssh.gradle
Created May 13, 2018 20:56 — forked from chilicat/scp-ssh.gradle
A simple gradle task to upload a file via SCP to a remote host and to execute a command via SSH on a remote host.
repositories { mavenCentral() }
configurations { sshAntTask }
dependencies { sshAntTask 'org.apache.ant:ant-jsch:1.9.2' }
ant.taskdef(
name: 'scp',
classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
classpath: configurations.sshAntTask.asPath)