Skip to content

Instantly share code, notes, and snippets.

@amendezcabrera
amendezcabrera / merry_christmas.html
Created December 24, 2023 19:08
Merry Christmas
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Merry Christmas</title>
<style>
body {
background-color: #ffe0e0;
margin: 0;
@amendezcabrera
amendezcabrera / main.dart
Created December 11, 2023 23:18
Widget Fade In Flutter Demo
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: FadeInDemo(),
);
@amendezcabrera
amendezcabrera / time_picker_widget.dart
Created February 16, 2023 21:07
A text form field widget to open a time picker on its tap
import 'package:flutter/material.dart';
class TimePickerWidget extends StatefulWidget {
TimePickerWidget({Key? key, required this.onTimeSelected, required this.label}) : super(key: key);
final String label;
final Function(TimeOfDay) onTimeSelected;
@override
@amendezcabrera
amendezcabrera / main.dart
Last active September 2, 2022 21:41
Setting default locale in Flutter
// Dependencies: [flutter_localizations](https://docs.flutter.dev/development/accessibility-and-localization/internationalization) (Official)
MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
title: ref.watch(currentStallProvider)?.place?.name ?? '',
theme: MainTheme.theme,
home: MyHomePage(
title: ref.watch(currentStallProvider)?.place?.name ?? ''))
@amendezcabrera
amendezcabrera / add_text_to_image.sh
Last active February 24, 2017 08:56
Bash script to create multiple instances of an image with different texts in each one
# Requirements: imagemagick
# Usage: add_text_to_image.sh FileWithTextLines.txt
#!/bin/bash
COUNTER=1
while IFS='' read -r line || [[ -n "$line" ]]; do
echo "Text to insert ($COUNTER): $line"
convert -pointsize 36 -draw "text 390,135 '$line'" imgsrc.png imgdst$COUNTER.png
let COUNTER=COUNTER+1
done < "$1"
<?php
function get_tls_version($sslversion = null)
{
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "https://www.howsmyssl.com/a/check");
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
if ($sslversion !== null) {
curl_setopt($c, CURLOPT_SSLVERSION, $sslversion);
}
@amendezcabrera
amendezcabrera / ssh-telegram.sh
Created January 22, 2017 21:01 — forked from matriphe/ssh-telegram.sh
Bash Script to notify via Telegram Bot API when user log in SSH
# save it as /etc/profile.d/ssh-telegram.sh
# use jq to parse JSON from ipinfo.io
# get jq from here http://stedolan.github.io/jq/
USERID="<target_user_id>"
KEY="<bot_private_key>"
TIMEOUT="10"
URL="https://api.telegram.org/bot$KEY/sendMessage"
DATE_EXEC="$(date "+%d %b %Y %H:%M")"
TMPFILE='/tmp/ipinfo-$DATE_EXEC.txt'
if [ -n "$SSH_CLIENT" ]; then
@amendezcabrera
amendezcabrera / AnimateDrawerCloseButton.java
Created October 27, 2016 18:28 — forked from dolphinziyo/AnimateDrawerCloseButton.java
Moves a custom "close drawer button" and changes its alpha according to the Navigation Drawer opening offset
/**
* Moves a custom "close drawer button" and changes its alpha according to the Navigation Drawer opening offset
* @param offset Drawer opening offset
*/
private void animateDrawerCloseButton(float offset) {
imbtnCloseDrawerButton.setX(recyclerView.getX() + recyclerView.getWidth() + convertDpiToPixels(15)); // (15) Distance between the button and the Drawer
offset *= 255; // (255) Max alpha
imbtnCloseDrawerButton.getDrawable().setAlpha((int) offset);
}
@amendezcabrera
amendezcabrera / AnimateLayout.java
Created October 27, 2016 18:28 — forked from dolphinziyo/AnimateLayout.java
Animate a Layout using the Android Property Animation System
private void animateLayout(boolean mostrar) {
AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.slide_in_up);
set.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
layout.setVisibility(View.GONE);
@amendezcabrera
amendezcabrera / SetImageButtonTintOnTouch.java
Created October 27, 2016 18:27 — forked from dolphinziyo/SetImageButtonTintOnTouch.java
Changes the tint of all the ImageButton sent via parameter
private Rect rect;
public void setImageButtonTintOnTouch(ImageButton... listaImbtn) {
for (ImageButton imbtn : listaImbtn) {
imbtn.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
rect = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
((ImageButton) v).setColorFilter(Color.argb(100, 0, 0, 0)); // Can cause ClassCastException
} else if (event.getAction() == MotionEvent.ACTION_UP) {