Skip to content

Instantly share code, notes, and snippets.

@Gongcu
Gongcu / AlarmService.java
Created March 5, 2020 11:43
Background Service(JobIntentService) + BroadcastReceiver
package com.health.myapplication.alarm;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
@FinnWoelm
FinnWoelm / read-text-message.sh
Created December 27, 2019 14:01
How to read text messages from USB modem
# Full instructions: http://manpages.ubuntu.com/manpages/bionic/en/man8/mmcli.8.html
# Examples: http://manpages.ubuntu.com/manpages/bionic/en/man8/mmcli.8.html#examples
# Supported modems: https://www.freedesktop.org/wiki/Software/ModemManager/SupportedDevices/
# Get list of connected modems.
mmcli --list-modems
# Output:
# Found 1 modems:
# /org/freedesktop/ModemManager1/Modem/1 [huawei] E3531
# The number at the end of the path is the modem index.
@pythoneast
pythoneast / permissions.py
Created September 18, 2019 05:20
Group based permissions for Django Rest Framework
from django.contrib.auth.models import User, Group
from rest_framework import permissions
def is_in_group(user, group_name):
try:
return Group.objects.get(name=group_name).user_set.filter(id=user.id).exists()
except Group.DoesNotExist:
return False
class HasGroupPermission(permissions.BasePermission):
@stevecohenfr
stevecohenfr / .python-gsmmodem-advanced.md
Last active August 9, 2025 13:49
Read long SMS with python-gsmmodem (and send SMS with same running script)

Read long SMS with python-gsmmodem (and send SMS with same running script)

I spend a lot of time to replace gammu with python-gsmmodem for my Huawei E3531.

The python exemple is just an exemple, it's incomplete. It does not read sms in the memory (if you receive a sms before starting the script). And it does not concat multiple parts sms (it will print unordered parts).
Also, as your live read sms script is running, you cannot send sms with another script because the dongle is busy.

Here is my own script to read all kind of SMS and send in same time.

@jsdaniell
jsdaniell / mui-datatable-crud-rows.js
Created July 25, 2019 13:41
Mui-Datatable with delete, add and edit options for rows.
import React from "react";
import ReactDOM from "react-dom";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import TextField from "@material-ui/core/TextField";
import Switch from "@material-ui/core/Switch";
import MUIDataTable from "mui-datatables";
import Cities from "./cities";
class Example extends React.Component {
constructor(props) {
@somoso
somoso / nginx-rtmp.conf
Created July 14, 2019 09:05
NGINX RTMP Config file for streaming h264 vid w/ mp3 audio
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
exec ffmpeg -threads 16 -re -i rtmp://localhost:1935/$app/$name -an -vcodec h264 -s 320x240 -f flv rtmp://localhost:1935/real/${name};
exec ffmpeg -threads 16 -re -i rtmp://localhost:1935/$app/$name -vn -acodec mp3 -q:a 9 -f flv rtmp://localhost:1935/audio/${name};
}
@grantpullen
grantpullen / Kannel with Postgresql DLR storage.md
Created June 24, 2019 12:15
Kannel with Postgresql DLR storage

Kannel with Postgresql DLR storage

Create the dlr table in PostgreSQL

  • Must add WITH OIDS to the CREATE statment since kannel expects old PostgreSQL behaviour.
  • Optionally add extra column created_at to keep track of old DLR. DLR entries are automatically removed by kannel once the final dlr is received from the SMSC. In cases where this message is not received, the DLR will not be removed. A cron job can be setup to remove old DLR by comparing the current time to created_at.
CREATE TABLE dlr (
    smsc        VARCHAR(48),
    ts          VARCHAR(48),
    destination VARCHAR(48),
@plateaukao
plateaukao / image_remove_backgroun.dart
Created April 13, 2019 05:18
image remove background in flutter
Future<Uint8List> _downloadImage() async {
String dir = (await getApplicationDocumentsDirectory()).path;
File file = new File('$dir/$_filename');
if (file.existsSync()) {
var image = await file.readAsBytes();
return image;
} else {
var response = await http.get(_url,);
var bytes = response.bodyBytes;
@huozhi
huozhi / simulate_mouse_action.js
Created March 31, 2019 14:14
simulate click and hover mouse action on web with js
const mouseEventOf = (eventType) => (element, x, y) => {
const rect = element.getBoundingClientRect()
const event = new MouseEvent(eventType, {
view: window,
bubbles: true,
cancelable: true,
clientX: rect.left + x,
clientY: rect.top + y,
})
@afriza
afriza / install-nginx-rtmp-module.sh
Last active December 31, 2023 22:04
Install NGINX RTMP module with HLS support on Ubuntu 18.04
sudo apt install curl gnupg2 ca-certificates lsb-release
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
sudo apt update
NGINX_VERSION=$(apt show nginx | grep "^Version" | cut -d " " -f 2 | cut -d "-" -f 1)
# take note of the nginx version in the "stable" release. e.g. 1.14.2
echo NGINX version $NGINX_VERSION
wget https://hg.nginx.org/pkg-oss/raw-file/default/build_module.sh
chmod a+x build_module.sh