Skip to content

Instantly share code, notes, and snippets.

View eliezedeck's full-sized avatar

Elie Zedeck RANDRIAMIANDRIRAY eliezedeck

View GitHub Profile
@eliezedeck
eliezedeck / textfield_focus.dart
Last active December 16, 2020 18:04
Detect `TextField` focus/unfocus (focus and blur in HTML terminology)
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
@eliezedeck
eliezedeck / set-date-without-ntp.sh
Created September 11, 2019 05:55
Set the system date using nothing but cURL (works even with broken clock, or boards without battery-powered RTC)
sudo date +"%d%m%Y%H%M%S" -s "$(curl -v --insecure --silent https://google.com/ 2>&1 | grep -i -E -w '^< date\:' | sed -e 's/< date: //gI')"
NAME='container-name'
# Things to know and understand
# - Docker needs to run at least one process inside, this is the command (CMD in Dockerfile)
# that defines the lifetime of the container
# - Docker will stop the container if the CMD stops
# - It is possible to run multiple processes inside one container (like from a shell)
# - Supervisor is a recommended tool to spawn and manage many processes
# Create + Run (run always creates a new container)
## Exception handling
try:
raise newException(IOError, "the drive is dirty")
except IOError:
echo "I/O error: " & getCurrentExceptionMsg()
@eliezedeck
eliezedeck / Valgrind.sh
Last active August 29, 2015 14:21
Valgrind quick reference.
# Memory leak check
valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all program_name
# Warning: not GC-safe: 't' [GcUnsafe] -- generated when using objects (t here) that have closures as member.
# Compile with --threads:on
type
TTTTT = object
onCalled: proc(i: int) {.closure.}
var
t: TTTTT # <== This is GCed, so the whole 't' instance is not gcsafe
x = 0