Skip to content

Instantly share code, notes, and snippets.

@primaryobjects
primaryobjects / hotspot-keep-alive.ps1
Last active June 30, 2024 20:28
Script to Enable Windows 10 Mobile Hotspot Automatically After Reboot
# https://superuser.com/a/1434648
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
$netTask.Result
@tony722
tony722 / sendmail-gcloud
Last active May 5, 2024 19:47
Freepbx Voicemail Transcription Script: Google Speech API
#!/bin/sh
# sendmail-gcloud
#
# Installation instructions
# Copy the content of this file to /usr/sbin/sendmail-gcloud
#
# Google Account
# ---------------
# Create a Google Cloud account if you don't have one yet. Free trial is available at https://console.cloud.google.com/freetrial
@tashirka1
tashirka1 / admin.py
Created December 10, 2018 16:39 — forked from gauravvjn/admin.py
Use JSONField properties in Django admin filter Raw
# You have a model something like this
from django.contrib.postgres.fields import JSONField
class MyModel(models.Model):
jsonfield = JSONField() # {"name": "Gaurav", "age": "25", "address": {"country": "India", "city": "Jaipur"}}
# few more fields...
# And in admin you want to create filter for jsonfield properties/keys
# for e.g. in above case we want to show filter for age and country
@gauravvjn
gauravvjn / admin.py
Last active August 17, 2023 20:27
Use JSONField properties in Django admin filter Raw
"""
More details on the implementation and usage can be found at
https://www.pyscoop.com/django-jsonfield-attributes-in-admin-filter/
"""
from django.contrib import admin
from django.core.exceptions import ImproperlyConfigured
class JSONFieldFilter(admin.SimpleListFilter):
@lgaetz
lgaetz / sendmail-bluemix
Last active September 13, 2022 14:01
Asterisk voicemail mailcmd script for VM transcription
#!/bin/sh
# sendmail-bluemix
# current verison of this script: https://gist.github.com/lgaetz/2cd9c54fb1714e0d509f5f8215b3f5e6
#
#
# Original source created by N. Bernaerts: https://github.com/NicolasBernaerts/debian-scripts/tree/master/asterisk
# modified per: https://jrklein.com/2015/08/17/asterisk-voicemail-transcription-via-ibm-bluemix-speech-to-text-api/
#
#
@Geekfish
Geekfish / merge_pdfs.py
Created January 31, 2017 16:07
pyPDF2 merge 2 pdf pages into one
from PyPDF2 import PdfFileReader, PdfFileWriter
from PyPDF2.pdf import PageObject
reader = PdfFileReader(open("invoice.pdf",'rb'))
invoice_page = reader.getPage(0)
sup_reader = PdfFileReader(open("supplement.pdf",'rb'))
sup_page = sup_reader.getPage(1) # We pick the second page here
translated_page = PageObject.createBlankPage(None, sup_page.mediaBox.getWidth(), sup_page.mediaBox.getHeight())
@bmihelac
bmihelac / wagtail_struct_block_validation.py
Created January 5, 2017 15:28
Example validating wagtail StructBlock
from django.core.exceptions import ValidationError
from django.forms.utils import ErrorList
from wagtail.wagtailcore import blocks
class MyLinkBlock(blocks.StructBlock):
"""
Example validating StructBlock.
"""
@brigand
brigand / .md
Last active August 26, 2016 20:28
immutable updates methods

Let's explore a few ways to do immutable updates in js. We'll start with this data:

var data = {
  foo: {
    bar: 1,
    baz: 2,
  }
};
@SQiShER
SQiShER / docker_stats_with_names.sh
Last active May 5, 2020 07:35
Docker stats with Container Names instead of IDs
docker stats $(docker inspect -f '{{.Name}}' $(docker ps -q) | cut -c 2-)
@iansltx
iansltx / _safari-iframe-cookie-workaround.md
Last active April 7, 2024 15:44
Safari iframe cookie workaround