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,
}
};
# 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 |
#!/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 |
# 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 |
""" | |
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): |
#!/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/ | |
# | |
# |
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()) |
from django.core.exceptions import ValidationError | |
from django.forms.utils import ErrorList | |
from wagtail.wagtailcore import blocks | |
class MyLinkBlock(blocks.StructBlock): | |
""" | |
Example validating StructBlock. | |
""" |
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,
}
};
docker stats $(docker inspect -f '{{.Name}}' $(docker ps -q) | cut -c 2-) |