Skip to content

Instantly share code, notes, and snippets.

View gregszero's full-sized avatar
🤙

Gregory gregszero

🤙
  • Curitiba
  • 14:34 (UTC -03:00)
View GitHub Profile
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
contract Lottery {
address public manager;
address payable[] public candidates;
address payable public winner;
constructor(){
@gregszero
gregszero / disable_attachment.js
Created September 16, 2023 19:47
Disable File Attachment on Trix Editor
(function() {
addEventListener("trix-initialize", function(e) {
const file_tools = document.querySelector(".trix-button-group--file-tools");
file_tools.remove();
})
addEventListener("trix-file-accept", function(e) {
e.preventDefault();
})
})();
@gregszero
gregszero / flutter_build.yml
Last active February 4, 2021 18:07
Build and Upload generated apk as artifact with GitHub Actions
name: Flutter Build
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
build:
@gregszero
gregszero / Damaged File MacOS
Created June 27, 2020 20:16
Run "damaged" apps in MacOS
xattr -cr App.app
@gregszero
gregszero / DateExtension.swift
Created January 31, 2018 15:17
Easy to use add and remove days to a Date
extension Date {
/// Returns a Date with the specified days added to the one it is called with
func add(years: Int = 0, months: Int = 0, days: Int = 0, hours: Int = 0, minutes: Int = 0, seconds: Int = 0) -> Date {
var targetDay: Date
targetDay = Calendar.current.date(byAdding: .year, value: years, to: self)!
targetDay = Calendar.current.date(byAdding: .month, value: months, to: targetDay)!
targetDay = Calendar.current.date(byAdding: .day, value: days, to: targetDay)!
targetDay = Calendar.current.date(byAdding: .hour, value: hours, to: targetDay)!
targetDay = Calendar.current.date(byAdding: .minute, value: minutes, to: targetDay)!
@gregszero
gregszero / Principal.js
Created March 25, 2017 01:53
Jhipster get Principal (current user)
Principal.identity().then(function (user) {
});
@gregszero
gregszero / Example.state.js
Last active February 8, 2017 13:04
Remove JHipster modal on edit/new action.
.state('example-detail', {
parent: 'entity',
url: '/example/{id}',
data: {
authorities: ['ROLE_USER'],
pageTitle: 'Example.example.detail.title'
},
views: {
'content@': {
templateUrl: 'app/entities/example/example-detail.html',
@gregszero
gregszero / image_extension.swift
Created January 12, 2017 17:45
Load image async with SDWebImage
//
extension UIImageView {
func loadFromUrl(url: String?) {
if let url = url {
self.sd_setImageWithURL(NSURL(string: "\(url)"))
}
}
}
#! /bin/bash
#
cd $(dirname "$0")
base=1024x1024.png
if [ -z $base ]
then
echo No argument given
else
import UIKit
extension String {
subscript (r: CountableClosedRange<Int>) -> String {
get {
let startIndex = self.index(self.startIndex, offsetBy: r.lowerBound)
let endIndex = self.index(startIndex, offsetBy: r.upperBound - r.lowerBound)
return self[startIndex...endIndex]
}