Skip to content

Instantly share code, notes, and snippets.

@Schwusch
Schwusch / pdf_diff.py
Last active September 4, 2017 08:38
Compare pdfs with different versions in bulk
# Dependencies: Python 3+, ImageMagick
from os import listdir, system, makedirs
from os.path import isfile, join, splitext
from multiprocessing import Pool
import errno
import argparse
def make_sure_path_exists(path):
try:
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names
import 'package:flutter/material.dart';
class BreathingWidget extends StatefulWidget {
final Widget child;
const BreathingWidget({Key key, @required this.child}) : super(key: key);
@override
_BreathingWidgetState createState() => _BreathingWidgetState();
}
@Schwusch
Schwusch / tiltable_stack.dart
Last active October 29, 2022 12:58
A tiltable stack, an idea originated from 2dimensions
import 'package:flutter/material.dart';
class TiltableStack extends StatefulWidget {
final List<Widget> children;
final Alignment alignment;
const TiltableStack({
Key key,
this.children,
this.alignment = Alignment.center,
@Schwusch
Schwusch / adbwificonnect.sh
Created August 17, 2019 10:11 — forked from amanshuraikwar/adbwificonnect.sh
Shell script to connect a USB connected device via adb over WiFi
# Purpose: Shell script to connect a USB connected device via adb over WiFi
#
# Author: Amanshu Raikwar
#
# Assumptions:
# 1. USB debugging is enabled in the Android device
# 2. The Android device is connected to the computer via USB
# 3. The Android device is connected to the same wifi as the computer
# 4. The Android device is accessible through port 5555 over the wifi network
#
@Schwusch
Schwusch / runnable_tilt_example.dart
Last active December 5, 2019 10:01
blog_examples
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
home: TiltedPyramid(),
);
}
@Schwusch
Schwusch / dangerous_update.kt
Created November 5, 2019 14:46
A hacky way of updating an object with another objects data. This is a really bad pattern kids
/**
* Loops through all fields in the receiving object and looks for fields
* with the same name in the sending object. Then it tries to copy non-null
* values to the receiving object, and silently fails when something goes wrong
*
* Don't use this
*/
fun Any.update(new: Any) = javaClass.declaredFields.forEach { field ->
try {
field.isAccessible = true
extension ScopingFunctions<T> on T {
/// Calls the specified function [block] with `this` value
/// as its argument and returns its result.
R let<R>(R Function(T) block) => block(this as T);
/// Calls the specified function [block] with `this` value
/// as its argument and returns `this` value.
T also(void Function(T) block) {
block(this as T);
return this as T;
void main() {
Foo? foo;
foo?.bar ??= 666;
print(foo);
foo = Foo()..bar = 666;
print(foo.bar);