Skip to content

Instantly share code, notes, and snippets.

View samuelantonioli's full-sized avatar

Samuel Antonioli samuelantonioli

View GitHub Profile
@samuelantonioli
samuelantonioli / mac-notification.py
Created February 8, 2021 14:25
mac-notification.py
import os
def notify(title, msg = ''):
'''small osascript notification with proper quotes escaping. don't use this with user input!'''
clean_str = lambda x: x.replace('"', '\\"').replace('\'', '\'\\\'\'')
os.system('osascript -e \'display notification "{}" with title "{}"\''.format(
clean_str(msg),
clean_str(title)
))
@samuelantonioli
samuelantonioli / cache.php
Last active February 8, 2021 14:46
PHP Simple File Cache with Lifetime Strategy
<?php
/***
*
* CACHE
*
* create the cache_directory BEFORE you use this cache.
* it doesn't generate it automatically to avoid possible bugs.
*
***/
@samuelantonioli
samuelantonioli / setup.sh
Last active July 4, 2021 23:24
wire-server setup using fake dependencies
#!/bin/bash
# chmod +x setup.sh && ./setup.sh
# [!] only for testing! this is not stable or secure
# it takes some hours.
# it is available under http://<server-ip>:8080
#
# make sure that you run ubuntu 16.04
# you need minimum 25gb (10gb filled with build dependencies)
@samuelantonioli
samuelantonioli / working-time.py
Last active May 27, 2018 21:43
python working time snippet
import datetime
def is_working_time(dt = None):
'''
is it currently working time?
tuesday at 8am - yes
saturday - no
'''
@samuelantonioli
samuelantonioli / sendmail.py
Last active January 31, 2019 10:07
Python Send Mail with Attachments
######
#
# short snippet to send a mail with python
# with mail attachments
#
# - always handy to have such a code snippet
# - should work on python 2.x and 3.x
# - supports multiple recipients
# - based on https://docs.python.org/3.1/library/email-examples.html
# - please do proper error handling in production
@samuelantonioli
samuelantonioli / ParseObjectPOJO.js
Last active March 6, 2021 02:06
Vue.js and Parse.Object
/**
*
* Vue.js and Parse.Object
*
* Transform Parse.Object into POJO so we can use it in Vue.js
* Make it possible to use the Parse.Object and sync changes to the model data.
* Easily $fetch and $save model data.
*
* needs:
* - Lodash
@samuelantonioli
samuelantonioli / scp_changed.py
Last active August 31, 2017 15:11
scp_changed - upload modified files of your git repository to your server
#!/usr/bin/env python
'''
# scp_changed
Upload changed files in a git repository to a server that has a copy of the project
## installation
save it as scp_changed
@samuelantonioli
samuelantonioli / models.js
Created August 15, 2017 09:54
Use Backbone.Model / Parse.Object with Vue.js or React
/**
* in models.js (example)
**/
import setup_object from './utils/setup_object'
var Model = Backbone.Model.extend({
constructor: function() {
setup_object(this);
Backbone.Model.apply(this, arguments);
},
@samuelantonioli
samuelantonioli / font-smoothing.js
Created July 30, 2017 17:12
Font Smoothing Fix
/**
* if you try to apply font smoothing
* using css rules you'll notice that
* Chrome ignores it
* because antialiasing under Mac OSX
* is deprecated (for good reasons).
*
* This workaround fixes this.
* You should only use this if you
* know what implications it has,