Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Andreas anka

🎯
Focusing
View GitHub Profile
@anka
anka / schedule.rb
Last active Jul 15, 2021
Example schedule.rb to use flock as a background job mutex
View schedule.rb
# 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 Nov 27, 2019
Dart class implementation to share files with platform-specific code using a MethodChannel
View share.dart
/// 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 Nov 27, 2019
iOS share method for sharing a file through Flutter's platform channel using UIActivityViewController
View AppDelegatePart.swift
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 Nov 27, 2019
iOS app delegate implementing a Flutter method channel for file sharing
View AppDelegate.swift
@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 Nov 27, 2019
Android main activity implementing a Flutter method channel for file sharing
View MainActivity.kt
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 Apr 12, 2019
GitLab CI configuration to lint and build Docker images and push them to AWS ECR
View .gitlab-ci.yml
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