Skip to content

Instantly share code, notes, and snippets.

@mateuszbaluch
mateuszbaluch / cloudflare.sh
Last active April 13, 2020 12:26 — forked from Manouchehri/cloudflare.sh
Allow CloudFlare only
# Source:
# https://www.cloudflare.com/ips
# https://support.cloudflare.com/hc/en-us/articles/200169166-How-do-I-whitelist-CloudFlare-s-IP-addresses-in-iptables-
# create new chains
iptables -N CF 2>/dev/null
ip6tables -N CF 2>/dev/null
# clear chains
iptables -F CF
ip6tables -F CF
speech = SpeechRecognizer.createSpeechRecognizer(this);
speech.setRecognitionListener(new RecognitationListener(this));
public void onVoiceActivation(View view) {
Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "pl_PL");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, view.getContext().getPackageName());
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
this.speech.startListening(recognizerIntent);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
view.findViewById(R.id.voice_activation_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onVoiceActivation(view);
}
});