Skip to content

Instantly share code, notes, and snippets.

View anka's full-sized avatar

Andreas anka

View GitHub Profile
@anka
anka / schedule.rb
Last active July 15, 2021 07:42
Example schedule.rb to use flock as a background job mutex
# frozen_string_literal: true
require 'digest'
# The command pattern to use. Note that placeholders like :path
# :task and :output will be replaced by whenever.
RAKE_COMMAND = 'cd :path && bundle exec rails :task --silent :output'
# Helper method for uniq file locks
def wrap_with_lock(prefix, command)
@anka
anka / share.dart
Created November 27, 2019 16:02
Dart class implementation to share files with platform-specific code using a MethodChannel
/// The Share class provides capabilities to share
/// content with platform-specific sharing dialogs
/// using a method channel.
class Share {
static const MethodChannel _channel = const MethodChannel('jademind.com/share');
/// Share a file with other apps.
///
/// Pass a [rect] to indicate the position a share
/// action was initiated from.
@anka
anka / AppDelegatePart.swift
Created November 27, 2019 15:57
iOS share method for sharing a file through Flutter's platform channel using UIActivityViewController
func shareFile(arguments:Any?) -> Void {
let argsMap = arguments as! NSDictionary
let subject = argsMap.value(forKey: "subject") as? String
let filepath = argsMap.value(forKey: "filepath") as? String
let x = argsMap.value(forKey: "x") as? NSNumber
let y = argsMap.value(forKey: "y") as? NSNumber
let width = argsMap.value(forKey: "width") as? NSNumber
let height = argsMap.value(forKey: "height") as? NSNumber
@anka
anka / AppDelegate.swift
Created November 27, 2019 15:55
iOS app delegate implementing a Flutter method channel for file sharing
@objc class AppDelegate: FlutterAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Receive the share method channel
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
let shareChannel = FlutterMethodChannel(name: "jademind.com/share", binaryMessenger: controller.binaryMessenger)
// Register a callback handler
shareChannel.setMethodCallHandler({
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
@anka
anka / MainActivity.kt
Created November 27, 2019 15:51
Android main activity implementing a Flutter method channel for file sharing
class MainActivity : FlutterActivity() {
private val SHARE_CHANNEL = "jademind.com/share"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
GeneratedPluginRegistrant.registerWith(this)
MethodChannel(flutterView, SHARE_CHANNEL).setMethodCallHandler { call, result ->
if (call.method.equals("share-file")) {
val argsMap = call.arguments as HashMap<String, String>
@anka
anka / .gitlab-ci.yml
Created April 12, 2019 13:10
GitLab CI configuration to lint and build Docker images and push them to AWS ECR
stages:
- Lint images
- Build and publish images
## Load a node.js image, install dockerlint and lint all Dockerfiles
linting:
stage: Lint images
image: node:4-alpine
script:
- npm install -g dockerlint && npm cache clean