Skip to content

Instantly share code, notes, and snippets.

View ruan65's full-sized avatar
🎯
Focusing

Andrew ruan65

🎯
Focusing
View GitHub Profile
@ruan65
ruan65 / exclude_rgex.txt
Created July 19, 2017 10:32
Exclude text in the android logcat
^(?!.*(Choreographer)).*$
// MARK: TextViewDelegate methods for hiding keyboard by tapping anywhere and restrincting 500 chars
extension UIViewController {
@objc func textViewDidBeginEditing(_ textView: UITextView) {
}
@objc func textViewDidEndEditing(_ textView: UITextView) {
@ruan65
ruan65 / java_write_to_file_exampe.java
Last active January 19, 2018 10:18
java write to file exampe
@RequestMapping(value = "/change/text", method = RequestMethod.POST)
public OutputMessage changeText(@RequestBody InputMessage msg) {
String fileName = "/home/a/temp/writtenByJava.txt";
System.out.println("Writing to file " + fileName);
writeToFileHelper(fileName, msg.getText());
return new OutputMessage(msg.getFrom(), msg.getText() + " - this is response!", new Date().toString());
@ruan65
ruan65 / bash.java
Created January 19, 2018 11:27
run bash via java
public static void main(String[] args) {
String[] cmd = new String[]{"/bin/sh", "/home/a/temp/notify.sh"};
try {
Process pr = Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
}
}
@ruan65
ruan65 / WebConfig.java
Created February 8, 2018 09:35
Controller method CORS configuration
// if localhost do not forget add http:// before url
package ru.redsys.event_manager_rea.configuration;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
package ru.redsys.rea_conference.network;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.app.JobIntentService;
import android.util.Log;
import org.greenrobot.eventbus.EventBus;
@ruan65
ruan65 / TmdbApi.kt
Created September 22, 2018 17:55 — forked from rubenpla-develop/TmdbApi.kt
#Kotlin #Android Retrofit2 singleton instance sample
package rubenpla.develop.privtmdbendlesslist.data.api
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.GET
import retrofit2.http.Query
import rubenpla.develop.privtmdbendlesslist.data.model.MoviesResultsItem
interface TmdbApi {
package premiumapp.org.jtimer.dialogs;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.Window;
/*
* Licensed Materials - Property of IBM
*
* (C) COPYRIGHT IBM CORP. 2015 All Rights Reserved
*
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with
* IBM Corp.
*/
@ruan65
ruan65 / maxidaemon.sh
Created January 31, 2019 11:00
service file maxidemon in /etc/init.d & maxidaemon.sh in /opt
#!/bin/bash
cd /home/dev/maxidroid/
su -c '(
until java -Xms512m -Xmx1024m -jar maxidroid_asio*.jar --jar.name=`ls | grep maxidroid_asio` --app.started=`date "+%d.%m.%Y_at_%H:%M:%S"` ; do
echo "Application crashed with exit code $?. Respawning... " >&2
sleep 5
done