投稿時間:2021-05-12 01:33:18 RSSフィード2021-05-12 01:00 分まとめ(49件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
AWS AWS News Blog AWS Local Zones Are Now Open in Boston, Miami, and Houston https://aws.amazon.com/blogs/aws/aws-local-zones-are-now-open-in-boston-miami-and-houston/ AWS Local Zones Are Now Open in Boston Miami and HoustonAWS Local Zones place select AWS services compute storage database and so forth close to large population industry and IT centers They support use cases such as real time gaming hybrid migrations and media amp entertainment content creation that need single digit millisecond latency for end users in a specific geographic area Last December I told you about … 2021-05-11 15:55:04
AWS AWS Architecture Blog Managing Asynchronous Workflows with a REST API https://aws.amazon.com/blogs/architecture/managing-asynchronous-workflows-with-a-rest-api/ Managing Asynchronous Workflows with a REST APIWhile building REST APIs architects often discover that they have particular operations that have to run in the background outside of the request processing scope Some of these may be “fire and forget ーthere is no need to report back to the clientーfor example when initiating a shipment For others the client may need a response … 2021-05-11 15:52:30
AWS AWS Database Blog Amazon DynamoDB single-table design using DynamoDBMapper and Spring Boot https://aws.amazon.com/blogs/database/amazon-dynamodb-single-table-design-using-dynamodbmapper-and-spring-boot/ Amazon DynamoDB single table design using DynamoDBMapper and Spring BootA common practice when creating a data model design especially in the relational database management system RDMS world is to start by creating an entity relationship diagram ERD Afterwards you normalize your data by creating a table for each entity type in your ERD design The term normalization refers to the process of organizing the … 2021-05-11 15:30:12
python Pythonタグが付けられた新着投稿 - Qiita Codeforces Round #510 (Div. 2) D. Petya and Array 座圧とセグメントツリー https://qiita.com/recuraki/items/626ad46ffd311a43a602 さて、最初に計算した累積和ですが、lから累積和を行うとです。 2021-05-12 00:34:37
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) openpyxlのopenpyxl.load_workbookを使いたい(環境:M1 Mac) https://teratail.com/questions/337787?rss=all 2021-05-12 00:56:49
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) model作成時のエラーについて https://teratail.com/questions/337786?rss=all model作成時のエラーについて前提・実現したいことmodelを作成したい発生している問題・エラーメッセージrailsでmodelを作成しようとしたら、エラーが発生しました。 2021-05-12 00:45:51
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Mac カーネルパニック https://teratail.com/questions/337785?rss=all 2021-05-12 00:44:53
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) C言語のリスト構造について https://teratail.com/questions/337784?rss=all 2021-05-12 00:44:08
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Vuetifyを使ったファイルをawsのs3にアップロードした際に日本語が文字化けしてしまいます。 https://teratail.com/questions/337783?rss=all Vuetifyを使ったファイルをawsのsにアップロードした際に日本語が文字化けしてしまいます。 2021-05-12 00:40:25
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) EXEファイルを呼び出し実行するbatファイルを、タスクスケジューラで起動できない https://teratail.com/questions/337782?rss=all プログラムを直接実行するとEXEファイルの実行も含めて正常に動作します。 2021-05-12 00:35:14
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) ショートカットプロパティ変更 https://teratail.com/questions/337781?rss=all 2021-05-12 00:02:05
Ruby Rubyタグが付けられた新着投稿 - Qiita 【Ruby】ゲッター/セッターとは https://qiita.com/peachbranch/items/20dd40ef2f9793836a49 ゲッター使い方classAnimaldefinitializenamenamenameenddefgetName「ゲッター」メソッドnameendenddogAnimalnewライオンゲッターメソッドを定義することで、クラスの外でもnameを取得できるpdoggetNamegtライオンセッターとはクラス外でインスタンス変数の値を変更したい時に使うのがセッターメソッド。 2021-05-12 00:57:04
Ruby Rubyタグが付けられた新着投稿 - Qiita 【devise】アカウント情報変更機能実装 https://qiita.com/Miyayan/items/36261b63dfaf5ff159e6 目的deviseを用いて、マイページ内にアカウント情報編集機能を実装する環境RubyonrailsverRubyverDockerverDockercomposever前提条件・gemDevise導入済み公式Github・マイページ実装済み参考私はusersコントローラーを自作し、showアクションにてマイページを実装しました。 2021-05-12 00:13:55
AWS AWSタグが付けられた新着投稿 - Qiita 【本番環境】【エラー解決】【備忘録】Failed to start The nginx HTTP and reverse proxy server.Unit nginx.service entered failed state.nginx.service failed. https://qiita.com/asami___t/items/e0cfd3c1e614d5ffd8c6 FailedtostartThenginxHTTPandreverseproxyserverUnitnginxserviceenteredfailedstatenginxservicefailed手順は下記参考記事の【手順Permissiveモードへの変更】のとおりです。 2021-05-12 00:50:08
Ruby Railsタグが付けられた新着投稿 - Qiita 【devise】アカウント情報変更機能実装 https://qiita.com/Miyayan/items/36261b63dfaf5ff159e6 目的deviseを用いて、マイページ内にアカウント情報編集機能を実装する環境RubyonrailsverRubyverDockerverDockercomposever前提条件・gemDevise導入済み公式Github・マイページ実装済み参考私はusersコントローラーを自作し、showアクションにてマイページを実装しました。 2021-05-12 00:13:55
海外TECH Ars Technica Amazon and others ordered to slash diesel pollution from warehouse trucks https://arstechnica.com/?p=1764041 commerce 2021-05-11 15:37:13
海外TECH DEV Community Games Every Programmer Should Play https://dev.to/abdurrehmaan/games-every-programmer-should-play-301g Games Every Programmer Should PlayProgramming games are often overlooked as a way to learn a new programming language or improve your knowledge of an existing one Here are few programming games that are worth a try CodinGameVisit CodinGame here CodinGame is one of the better known free platforms for learning how to code through games The platform supports over programming languages and comes with challenges that become gradually harder as you progress through them CodinGame is a community too You can solve challenges together with your friends or colleagues and learn how other players solve particular challenges CodemonkeyVisit Codemonkey here Codemonkey teaches codding using CoffeeScript a real programing language to teach you to build your own games in HTML It s aimed at codding for kids but it s definitely fun for adults too Flexbox FroggyVisit Flexbox Froggy here In this game you must bring the frogs home to their lilypads by mastering CSS flexbox a powerful new module that makes layout a breeze With it you can control alignment spacing and wrapping of elements on the webpage using only one or two lines of code CodeCombatVisit Code Combat here CodeCombat is a platform that gamifies Python JavaScript HTML and the fundamentals of computer science As you progress you ll unlock heroes pets gear and more The game is free for all its core levels with a a month subscription if you want access to its extra level branches plus bonus gems a month The game has a strong open source community that helps with translations and creating more levels UntrustedVisit Untrusted here Untrusted is a meta JavaScript adventure game written by Alex Nisnevich and Greg Shuflin You need to write or remove JavaScript code to create a gap in the walls surrounding you Contrary to some of the other suggestions in this list Untrusted is made for people already familiar with JavaScript It starts easy but the puzzles quickly become difficult If you re up for a challenge try Untrusted Cyber DojoVisit Cyber Dojo here cyber dojo is an online browser based coding dojo game cyber dojo is the world s simplest non development environment Each group writes their code and tests inside a web browser presses their run tests button to submit their code and tests to the cyber dojo server AI GamingVisit AI Gaming here Last but not the least we have Microsoft s AI Gaming Platform where you can code bots in python and compete against your friends on different games amp challenges You can also participate in tournaments to win some really cool prizes Along with learning to code a bot in Python you will also get hands on practice in using Microsoft s Cloud Platform Azure We hope you found at least one new programming game you ll enjoy playing There s nothing better than learning how to code while having fun in the process If you enjoyed this article please feel free to share it on social media clicking the buttons top right 2021-05-11 15:29:57
海外TECH DEV Community No need to handle Express.js with this MERN Stack project template https://dev.to/scaledynamics/no-need-to-handle-express-js-with-this-mern-stack-project-template-1bm6 No need to handle Express js with this MERN Stack project templateAt ScaleDynamics we have one recurrent passion to make web developers life easier BAM And we strike again We built a fully open source MERN template ready to use for our platform One command to develop with frontend and backend live reload One command to deploy on the cloud Let s get started It is located here use it as you wish and start coding your projects with it We hope you ll find it helpful A MERN template with a fully managed ExpressQuick reminder ーMERN stands for MongoDB Express React and Node js and is one of the several variations of the MEAN stack MongoDB Express Angular Node js It is one of the standard “Full Stack stack for JavaScript developers This template is configured for the ScaleDynamics web platform It is on MIT license and ready to be used to build your own MERN based apps services Everything is preconfigured we provide one command to develop with live reload frontend and backend and one to deploy to make it live on a URL One particularity of our platform is that you don t have to manage the Express js layers the platform manages them for you automatically so you can focus only on the MongoDB Node React coding You can stop coding HTTP JSON as it is now automatic thanks to our compiler It generates the HTTP JSON stubs required to call a Node js function using JS objects Please note that you need a ScaleDynamics platform account you can create your FREE Community account right here Diving into the templateTo start using the MERN template you can clone it git clone This project is divided in two parts the frontend where you can find a react app web template app located in the frontend react app folder It has been created with create react app To update it open the src folder where you can add modify or delete components the backend contains a hello node module and a MongoDB module You can update the frontend backend as you need to build your own app To start developing with the template go in frontend react app folder and run those commands To set up the projectnpm install To log onto the ScaleDynamics PlatformThen use your ScaleDynamics account credential to log onto the platform feel free to create a free community account here npx warp login Develop with live reloadTo enter a live reload development session use the command below Feel free to update the frontend or the backend code it will be rebuilt at each change npm run startPlease note that when running this command you have to select a project On the ScaleDynamics platform a project identifies an application or a microservice Select an existing project or create a new one For more details on projects see the documentation Deploying with ScaleDynamicsTo deploy your project you ll have first to compile and minify your project for production npm run buildThen use the deploy commandnpm run deployNote that when running this command you have to select a project and an environment On the ScaleDynamics platform a project identifies an application or a microservice Select an existing project or create a new one An environment identifies the cloud execution environment to run your app You can create as many as you want like staging demo prod Each environment has its own URL To deploy select an existing environment or create a new one For more details on projects or environments see the documentation Configure MongoDB driverRegarding MongoDB we provide a template module in the src mongodb js To use your own MongoDB instance replace the URI constant by your own const URI mongodb username password host port hostN portN defaultauthdb options You re all set Creating new functionsYou can create new functions that can be called by the frontend Add them in index js or into another module and export it The platform manages the Express js layers automatically const myFunction gt your code here module exports myFunction To access your new functions on the frontend side feel free to adapt this code import as Backend from backend hello js const myFunction new Backend Other infoAnd that s it If you need more information you can refer to the documentation ScaleDynamics PlatformReactMongoDBWe hope you liked it please let us know if you have any questions or feedback We have more template variations coming up for React so you can subscribe or follow us on Twitter Facebook and even Instagram if you wish 2021-05-11 15:28:26
海外TECH DEV Community EF Core multiple Database providers https://dev.to/moesmp/ef-core-multiple-database-providers-3gb7 EF Core multiple Database providersMost of the time you don t need to have multiple database providers for example you start with the SQL Server provider and there is no need to switch to another database provider In my recent project we have to add multiple providers to support different deployment environments Some customers prefer to use Windows Server and SQL Server database and others prefer to use Linux and MySQL or PostgreSQL In this walkthrough I show how to add SQL Server and PostgresSQL providers and configure them The default provider is SQL Server and the alternative provider is PostgreSQL Step Create a projectCreate ASP NET Core Web API Step Create Default DbContextAdd Data folder to the root of the projectAdd a WeatherDbContext to Data folder public abstract class WeatherDbContext DbContext protected readonly IConfiguration Configuration protected WeatherDbContext IConfiguration configuration Configuration configuration public DbSet lt WeatherForecast gt WeatherForecasts get set MsSqlDbContext is our default DbContext and we use this default DbContext every in code MsSqlDbContext contains DbSets and shared functionalities that we want use among all DbContext classes Step Create SQL Server DbContextAdd a MsSqlDbContext to Data folder public class MsSqlDbContext WeatherDbContext public MsSqlDbContext IConfiguration configuration base configuration protected override void OnConfiguring DbContextOptionsBuilder options options UseSqlServer Configuration GetConnectionString MsSqlConnection Instead of configuring SQL Server provider in ConfigureService method in Startup class services AddDbContext lt YourDbContext gt options gt options UseSqlServer Configuration GetConnectionString SomeConnection I configure provider in OnConfiguring method of MsSqlDbContext protected override void OnConfiguring DbContextOptionsBuilder options options UseSqlServer Configuration GetConnectionString MsSqlConnection Step Create PosgreSQL DbContextAdd a PostgresDbContext class to Data folder public class PostgresDbContext MsSqlDbContext public PostgresDbContext IConfiguration configuration base configuration protected override void OnConfiguring DbContextOptionsBuilder options options UseNpgsql Configuration GetConnectionString PostgreSqlConnection Step Registring DbContextsSo far we have two DbContexts but we want to choose a preferred database provider in the configuration file appsettings json Add following key valu to appsettings json DatabaseProvider MsSql Register database provider in ConfigureServices based on the selected provider public void ConfigureServices IServiceCollection services services AddControllers switch Configuration DatabaseProvider case MsSql services AddDbContext lt WeatherDbContext MsSqlDbContext gt break case PostgreSql services AddDbContext lt WeatherDbContext PostgresDbContext gt break Step MigrationsLet s generate a migration for SQL Server database Add Migrations MsSql folders to Data folderIn appsettings json file set MsSql value for DatabaseProvider keyRun the following command for generating migration SQL Server database Add Migration InitialDbMsSql Context MsSqlDbContext OutputDir Data Migrations MsSqlLet s generate a migration for PostgreSQL database Add Migrations PostgreSql folders to Data folderIn appsettings json file set PostgreSql value for DatabaseProvider keyRun the following command for generating migration SQL Server database Add Migration InitialDbPostgres Context PostgresDbContext OutputDir Data Migrations PostgreSql Step Entity ConfigurationHere is the WeatherForecast class public class WeatherForecast public int Id get set public DateTime Date get set public int TemperatureC get set public int TemperatureF gt int TemperatureC public string Summary get set Consider the following configuration internal class WeatherForecastConfiguration IEntityTypeConfiguration lt WeatherForecast gt public void Configure EntityTypeBuilder lt WeatherForecast gt builder builder Property wf gt wf TemperatureC HasColumnType tinyint builder Property wf gt wf Date HasColumnType datetime builder Property wf gt wf Summary HasColumnType nvarchar IsRequired false builder Ignore wf gt wf TemperatureF In the above configuration I used tinyint and nvarchar are supported in SQL Server but not supported in PostgreSQL In such a case you can move the configuration to OnModelCreating method DbContext public class MsSqlDbContext DbContext protected override void OnModelCreating ModelBuilder modelBuilder modelBuilder Entity lt WeatherForecast gt Property wf gt wf TemperatureC HasColumnType tinyint modelBuilder Entity lt WeatherForecast gt Property wf gt wf Date HasColumnType datetime modelBuilder Entity lt WeatherForecast gt Property wf gt wf Summary HasColumnType nvarchar IsRequired false And for PostgresDbContext public class PostgresDbContext MsSqlDbContext protected override void OnModelCreating ModelBuilder modelBuilder modelBuilder Entity lt WeatherForecast gt Property wf gt wf TemperatureC HasColumnType samllint modelBuilder Entity lt WeatherForecast gt Property wf gt wf Date HasColumnType timestamp modelBuilder Entity lt WeatherForecast gt Property wf gt wf Summary HasColumnType varchar IsRequired false I prefer to move specific configuration from OnModelCreating to configuration classes and makeOnModelCreating method clean with help of reflection but you can keep it as it is To move configurations Add Configurations folder to Data folder for common configuration of database providersAdd WeatherForecastSharedConfiguration class to Configurations folder internal class WeatherForecastSharedConfiguration IEntityTypeConfiguration lt WeatherForecast gt public void Configure EntityTypeBuilder lt WeatherForecast gt builder builder Ignore wf gt wf TemperatureF Add MsSql folder to Configurations folderAdd WeatherForecastMsSqlConfiguration class to MsSql folder internal class WeatherForecastMsSqlConfiguration IEntityTypeConfiguration lt WeatherForecast gt public void Configure EntityTypeBuilder lt WeatherForecast gt builder builder Property wf gt wf TemperatureC HasColumnType tinyint builder Property wf gt wf Date HasColumnType datetime builder Property wf gt wf Summary HasColumnType nvarchar IsRequired false Add PostgreSql folder to Configurations folderAdd WeatherForecastMsSqlConfiguration class to PostgreSql folder internal class WeatherForecastPostgresConfiguration IEntityTypeConfiguration lt WeatherForecast gt public void Configure EntityTypeBuilder lt WeatherForecast gt builder builder Property wf gt wf TemperatureC HasColumnType samllint builder Property wf gt wf Date HasColumnType timestamp builder Property wf gt wf Summary HasColumnType varchar IsRequired false Add the following codes to WeatherDbContext default DbContext to load shared and provider specific configuration protected override void OnModelCreating ModelBuilder modelBuilder ApplyConfiguration modelBuilder MsSql Configurations protected void ApplyConfiguration ModelBuilder modelBuilder string configNamespace var methodInfo typeof ModelBuilder GetMethods Single e gt e Name ApplyConfiguration amp amp e ContainsGenericParameters amp amp e GetParameters SingleOrDefault ParameterType GetGenericTypeDefinition typeof IEntityTypeConfiguration lt gt foreach var configType in typeof MsSqlDbContext GetTypeInfo Assembly GetTypes Where t gt t Namespace null amp amp t Namespace Contains configNamespace amp amp t GetInterfaces Any i gt i IsGenericType amp amp i GetGenericTypeDefinition typeof IEntityTypeConfiguration lt gt var type configType GetInterfaces First methodInfo MakeGenericMethod type GenericTypeArguments Invoke modelBuilder new Activator CreateInstance configType In OnModelCreating method of MsSqlDbContext protected override void OnModelCreating ModelBuilder modelBuilder var namespaces new EfMultipleProviders Data Configurations EfMultipleProviders Data Configurations MsSql ApplyConfiguration modelBuilder namespaces Load shared configuration from EfMultipleProviders Data Configurations namespace and SQL Server configuration from EfMultipleProviders Data Configurations MsSql namespace And for PsotgresDbContext protected override void OnModelCreating ModelBuilder modelBuilder var namespaces new EfMultipleProviders Data Configurations EfMultipleProviders Data Configurations PostgreSql ApplyConfiguration modelBuilder namespaces Do not use modelBuilder ApplyConfigurationsFromAssembly method to load configuration Inject WeatherDbContext into your repositories services or controller not MsMsqlDbContext or PostgresSqlDbContextYou can find the source code for this walkthrough on Github 2021-05-11 15:13:04
海外TECH DEV Community Printing on paper with Python 🖨️ https://dev.to/pa4kev/printing-on-paper-with-python-n79 Printing on paper with Python ️ The original print toolIn I was requested to create a solution for printing placards on paper These placards contained serial numbers an order number and other data related to racks with computer equipment This data had to be represented with QR codes and bar codes so that the warehouse could scan them I was given discarded Lenovo Ts laptops that were put in the assembly department so the personnel could use the application Because I was tied to Windows and had to create a GUI for easy usage I decided to create a C program in Microsoft Visual Studio because creating a GUI for Windows was very easy that way It would create local HTML files using the Barcode Rendering Framework NuGet package for creating QR and bar codes and send it to the printer set as default in Windows It even had some logging using NLog I just named this application print tool Original placardThe placard rendered by the C application The re implemented print toolIn I decided to integrate the print tool into another program written in Python using the Qt GUI toolkit This program was a Python re write of another C project of mine And the PyQt binding really allows for a nice GUI creation with the Qt Designer For the QR codes I used the qrcode python module It easily generates PNG files It is as simple as import qrcodeqrcode make For bar codes I used the python barcode module In the original print tool I used HTML files and printed them The WebBrowser class handled printing of documents which was convenient private void PrintDocument object sender WebBrowserDocumentCompletedEventArgs e Print the document now that it is fully loaded WebBrowser sender Print Dispose the WebBrowser now that the task is complete WebBrowser sender Dispose private void PrintHelpPage Uri uri logger Info String Format Print uri Create a WebBrowser instance WebBrowser webBrowserForPrinting new WebBrowser Add an event handler that prints the document after it loads webBrowserForPrinting DocumentCompleted new WebBrowserDocumentCompletedEventHandler PrintDocument Set the Url property to load the document webBrowserForPrinting Url uri But with Python this proved a little difficult I used the to winapi module for printing Which calls an application set in Windows registry to use an print the file winapi ShellExecute print filename f d winprint GetDefaultPrinter Python uses this print verb to let Windows direct a file to a printer This is called a File Association These file associations can be found in Windows Registry Here are some examples C Program Files x Adobe Acrobat Reader DC Reader AcroRd exe p h SystemRoot system NOTEPAD EXE p ProgramFiles Windows NT Accessories WORDPAD EXE p systemroot system mspaint exe p Printing the HTML files proved to be difficult Firefox used to have a command line parameter to do this which is still found in Windows Registry but this did not work Other programs simply printed out the HTML source I tried editing the print verb for HTML files but no luck Printing HTMLPrinting an HTML file with notepad or WordPad also did not work Moving away from HTML I used the xlsxwriter module I had experience with this module so it seemed a good choice I could generate an Excel worksheet tempfile and put a PNG image in there On my development laptop which had Excel installed the print verb for xlsx files was connected to the command C Program Files x Microsoft Office Root Office EXCEL EXE q While this did print on my development laptop the IT department did not want Excel installed on the Microsoft tablets Their reasoning was It required licensesIt costs valuable storage spaceIt impacts performanceAnd apparently there was an agreement somehow in the company that prohibited the installment of MS Office on these tablets This also ruled out generation of PDF files with PyPDF because I could not install Adobe Acrobat on these tablets either Using deprecated old software such as Excel Viewer and Excel Mobile would not be a good long term option either I then thought the WordPad application which is native to Windows would be a better choice It uses this command to print ProgramFiles Windows NT Accessories WORDPAD EXE p I then tried to generate RTF files with Python and include images in them The PyRTF module did allow me to generate RTF files with text and these properly printed as well But its image processing always rejected PNG and JPG images because it could not properly read and parse their binary headers Running out of options and ideas I decided to take a look at other file formats that WordPad could handle There I saw the odt extension for OpenDocument files These files have proven to be the perfect outcome I could choose between the odfpy module and the relatorio module With relatorio I could simply create a template file with OpenOffice Writer Load the template in Python fill in the data and images finally print it Here is a stand alone script I created during testing import qrcodeimport relatoriofrom relatorio templates opendocument import Templateimport tempfileimport timeimport winapiimport winprintdef generate qr qr input data holder with tempfile NamedTemporaryFile delete False suffix png as tmpfile qr qrcode make qr input qr save tmpfile qr format quality print tmpfile name return open tmpfile name rb image png def main inv inv shipmentnumber inv units inv model MyModel inv systemnumber inv productline TestLine inv page inv pagetotal inv ordernumber inv ordernumberqr generate qr inv ordernumber inv basic Template source filepath basic odt with open placard odt wb as f f write basic generate o inv render getvalue time sleep filename placard odt print f Printing filename winapi ShellExecute print filename f d winprint GetDefaultPrinter if name main main The above code works fine however When I tested my application on the tablet it printed black boxes instead of images It turns out that images that were embedded using placeholders in a template created in Word or OpenOffice Writer become like that when printed by WordPad While printing on my development machine I must have still used Word to have printed these documents Black boxesJust when you think you were finished Creating the ODF fileInstead of filling in a template file with placeholders and embed images I thought maybe I need to create the ODF file from scratch and insert the images more directly rather than use placeholders I turned to odfpy I created the document and viewed it in WordPad all looked fine inside the program But when printing black boxes came out yet again Here is the code used with odfpy from barcode codex import Codefrom barcode writer import ImageWriterimport qrcodeimport PIL Imagefrom PIL PngImagePlugin import PngImageFile PngInfofrom odf opendocument import OpenDocumentTextfrom odf import style textfrom odf text import Pfrom odf draw import Frame Imagefrom odf style import Style GraphicProperties TableColumnProperties ParagraphProperties TableCellPropertiesfrom odf table import Table TableColumn TableRow TableCellimport iofrom os path import join dirnameimport tempfileimport timeimport winapiimport winprintdef generate qr qr input str qr name with tempfile NamedTemporaryFile delete False suffix png as tmpfile qr qrcode QRCode version error correction qrcode constants ERROR CORRECT L box size border qr add data qr input qr make fit True img qr make image fill color black back color white img img convert RGB pixels img load pixels img save tmpfile name dpi qr name tmpfile name return qr namedef generate bar bar input str bar name with tempfile NamedTemporaryFile delete False suffix png as tmpfile Code bar input writer ImageWriter write tmpfile options write text False img PIL Image open tmpfile img img convert RGB pixels img load pixels img save tmpfile name dpi bar name tmpfile name return bar namedef main outfp io BytesIO textdoc OpenDocumentText p P text QR code placard textdoc text addElement p Main table tablecontents Style name Table Contents tablecontents addElement ParagraphProperties numberlines true linenumber textdoc styles addElement tablecontents widthshort Style name Wshort family table column widthshort addElement TableColumnProperties columnwidth textdoc automaticstyles addElement widthshort widthwide Style name Wwide family table column widthwide addElement TableColumnProperties columnwidth textdoc automaticstyles addElement widthwide table Table table addElement TableColumn numbercolumnsrepeated stylename widthshort table addElement TableColumn numbercolumnsrepeated stylename widthwide tr TableRow table addElement tr tc TableCell tr addElement tc tc addElement P stylename tablecontents text Shipment tc TableCell tr addElement tc tc addElement P stylename tablecontents text tc TableCell tr addElement tc tc addElement P stylename tablecontents text System tc TableCell tr addElement tc tc addElement P stylename tablecontents text textdoc text addElement table separate Images order number qr generate qr order number p P textdoc text addElement p photoframe Frame width px height px print f QR qr href textdoc addPicture qr photoframe addElement Image href href p addElement photoframe bar generate bar order number p P textdoc text addElement p photoframe Frame width px height px href textdoc addPicture bar photoframe addElement Image href href p addElement photoframe p P text End of placard textdoc text addElement p time sleep save tempfile with tempfile NamedTemporaryFile delete True as tmpfile textdoc save tmpfile name True print f Printing tmpfile name if name main main PNG file contentsI then tried to open the ODF file in Word then right click on the image of the QR code and use save as picture and then re add this new image back into WordPad When printing with the re added image the QR code was properly printed The image was slightly less quality and thus a little blurry pixelated due to compression artefacts This later was a clue to actually solve the problem I was able to also add other PNG files which also printed just fine I concluded the PNG image itself must be the problem not the way the ODF document is built Eventually I found a handy program TweakPNG specifically to inspect PNG files I learnt that PNG files are made up of chunks I used the Python Image Library Pillow module to convert the generated image into RGB This changed its header from bit sample grayscaleinto bits sample truecolorimg PIL Image open qr name img img convert RGB I also tried a palettised conversion mode img img convert P Which added a palette but this still printed out a black box I tried to copy the chunks of the PNG that did print into the QR and Bar code PNG images that Python generated The TweakPNG tool and the PIL module both allowed to easily change these chunks metadata PngInfo pnginfo add b grAb struct pack gt II PIL docs on this PIL PngImagePlugin PngInfoBut still no good Trying to copy the chunks as closely as possible WordPad still printed solid black boxes How coloured pixel solved the problemI mentioned how I was able to properly print the QR code I first opened in Word then use Save as picture to create a new PNG image of it which was slighly blurry because of compression artefacts I noticed that the artefacts were slightly grey I then tried an experiment With MS Paint I created a solid white image On that image I drew several black non aliased circles I drew another image also solid white background but with coloured circles I then added both these images manually to the ODF document and print it The image with the black circles got printed as a solid black box while the coloured circles got printed properly The chunk contents did not matter at all only the use of colour mattered Colour circle testTesting to see how WordPad printing respondsWordPad at least the version I was working with in apparently cannot handle images that are consistent of only black and white pixels If I added a single coloured pixel anywhere on the PNG WordPad suddenly is able to process the image properly for printing WordPad versionAbout WordPadUsing the PIL module to modify the QR and Bar code PNG images by adding red pixel and then add the image to the ODT document finally allowed proper printing I reverted back to the relatorio code and here is the final script import qrcodeimport relatoriofrom relatorio templates opendocument import Templatefrom os path import join dirnameimport tempfileimport timeimport winapiimport winprintdef generate qr qr input str qr name with tempfile NamedTemporaryFile delete False suffix png as tmpfile qr qrcode QRCode version error correction qrcode constants ERROR CORRECT L box size border qr add data qr input qr make fit True img qr make image fill color black back color white img img convert RGB pixels img load pixels img save tmpfile name dpi qr name tmpfile name return qr namedef main inv inv shipmentnumber inv units inv model MyModel inv systemnumber inv productline TestLine inv page inv pagetotal inv ordernumber inv ordernumberqr open generate qr inv ordernumber rb image png basic Template source filepath basic odt with open placard odt wb as f f write basic generate o inv render getvalue time sleep filename placard odt print f Printing filename winapi ShellExecute print filename f d winprint GetDefaultPrinter if name main main Yes I could colour the QR codes itself but adding a red pixel to resolve this after several days and much wasted paper just felt very gratifying to me Thank you for reading Final placard The enemy of art is the absense of limitations Orson Welles 2021-05-11 15:09:11
Apple AppleInsider - Frontpage News Brydge reveals Air Max+ keyboard & trackpad case for the iPad Air https://appleinsider.com/articles/21/05/11/brydge-reveals-air-max-keyboard-trackpad-case-for-the-ipad-air?utm_medium=rss Brydge reveals Air Max keyboard amp trackpad case for the iPad AirThe latest Brydge keyboard for the iPad Air is available for pre order and features a native multi touch trackpad backlit keyboard and magnetic attachment Brydge Air Max for the iPad Air and inch iPad ProThe latest Brydge keyboard for iPad Air comes after the Max and Max The Max series features a redesigned keyboard and trackpad with better connectivity Read more 2021-05-11 16:00:19
Apple AppleInsider - Frontpage News Deals: $110 to $200 off every M1 MacBook Pro w/ 16GB RAM, plus $60 off AppleCare https://appleinsider.com/articles/21/05/11/deals-110-to-200-off-every-m1-macbook-pro-w-16gb-ram-plus-60-off-applecare?utm_medium=rss Deals to off every M MacBook Pro w GB RAM plus off AppleCareThe best MacBook Pro deals are at AppleInsider this week with inch models equipped with Apple s M chip and GB of RAM to off on top of a markdown on AppleCare Top MacBook Pro discountsReaders in the market for Apple s latest inch MacBook Pro can save anywhere from to on every configuration equipped with GB of RAM using the activation links below and promo code APINSIDER The same coupon code also knocks off AppleCare for the inch MacBook Pro bringing the price down to when purchased alongside the system Read more 2021-05-11 15:50:41
Apple AppleInsider - Frontpage News Apple clarifies iCloud issue for Apple One subscribers with two Apple IDs https://appleinsider.com/articles/21/05/11/apple-clarifies-icloud-issue-for-apple-one-subscribers-with-two-apple-ids?utm_medium=rss Apple clarifies iCloud issue for Apple One subscribers with two Apple IDsUsers with a single Apple ID had no confusion when switching to an Apple One bundle subscription but people with two now have answers about iCloud storage Apple One includes extra iCloud storageOne of the benefits of the Apple One subscription bundle is that it includes extra iCloud storage space above the free GB that each user gets Whether you took the that base figure with the basic bundle or went for the TB option of Apple One Premier the storage space is added to iCloud for your Apple ID Read more 2021-05-11 15:34:09
Apple AppleInsider - Frontpage News Applications now open for Detroit Apple Developer Academy https://appleinsider.com/articles/21/05/11/applications-now-open-for-detroit-apple-developer-academy?utm_medium=rss Applications now open for Detroit Apple Developer AcademyMichigan State University has started taking applications to attend the Apple Developer Academy a code education program it is partnering with Apple on in Detroit The Detroit Apple Developer Academy announced in January and made in partnership with Michigan State University offers training to would be developers looking to get into app development On Tuesday potential candidates for the program were able to apply to take part According to the MSU site for the academy anyone aged years or older can apply for the one year program Students will be able to work on real world challenges and connect with community and industry partners Read more 2021-05-11 15:11:27
海外TECH Engadget Bose built the first FDA-cleared hearing aids that won't require a doctor's visit https://www.engadget.com/bose-soundcontrol-hearing-aids-152746656.html Bose built the first FDA cleared hearing aids that won x t require a doctor x s visitBose has unveiled its first hearing aids and they re the first in the US that don t require a doctor s visit or prescription ーyou can buy SoundControl directly 2021-05-11 15:27:46
海外TECH CodeProject Latest Articles Creating an MLOps Kubernetes Cluster on GKE https://www.codeproject.com/Articles/5302262/Creating-an-MLOps-Kubernetes-Cluster-on-GKE Creating an MLOps Kubernetes Cluster on GKEIn this article series we ll demonstrate how to take use a CI CD pipeline a tool usually used by developers and DevOps teams and demonstrate how to use it to create a complete training test and deployment pipeline for AI that meets the requirements of level in the Google MLOps Maturity 2021-05-11 15:41:00
海外科学 NYT > Science Biden Administration Approves Nation’s First Major Offshore Wind Farm https://www.nytimes.com/2021/05/11/climate/climate-wind-farm.html homes 2021-05-11 15:41:29
金融 RSS FILE - 日本証券業協会 株券等貸借取引状況(週間) https://www.jsda.or.jp/shiryoshitsu/toukei/kabu-taiw/index.html 貸借 2021-05-11 15:30:00
金融 RSS FILE - 日本証券業協会 インターネット取引に係るシステム障害件数 https://www.jsda.or.jp/shiryoshitsu/toukei/inter/index.html 取引 2021-05-11 15:20:00
金融 金融庁ホームページ 金融審議会「最良執行のあり方等に関するタスクフォース」(第4回)を開催します。 https://www.fsa.go.jp/news/r2/singi/20210511.html 最良執行 2021-05-11 17:00:00
金融 金融庁ホームページ 審判期日の予定を更新しました。 https://www.fsa.go.jp/policy/kachoukin/06.html 期日 2021-05-11 16:00:00
ニュース ジェトロ ビジネスニュース(通商弘報) 欧州産業連盟、欧州委の新産業戦略と外国補助金に対する規制案を歓迎 https://www.jetro.go.jp/biznews/2021/05/9625ce6877e109ee.html 連盟 2021-05-11 15:40:00
ニュース ジェトロ ビジネスニュース(通商弘報) 欧州鉄鋼連盟、鉄鋼需要の回復を予測、今後の国際競争環境には懸念 https://www.jetro.go.jp/biznews/2021/05/fec00c1a30330118.html 国際競争 2021-05-11 15:30:00
ニュース ジェトロ ビジネスニュース(通商弘報) 新型コロナ感染者の急増を受け、酸素の輸出を制限 https://www.jetro.go.jp/biznews/2021/05/437d4322a08c1c89.html 酸素 2021-05-11 15:20:00
ニュース ジェトロ ビジネスニュース(通商弘報) 4月のドイツ国内乗用車新規登録台数、前年の反動で急増 https://www.jetro.go.jp/biznews/2021/05/f4608226d78b2c1f.html 登録 2021-05-11 15:10:00
海外ニュース Japan Times latest articles Japanese government debt rises by record ¥101 trillion in fiscal 2020 https://www.japantimes.co.jp/news/2021/05/11/business/economy-business/japan-government-debt/ april 2021-05-12 01:14:20
海外ニュース Japan Times latest articles Household spending falls 4.9% in fiscal 2020, second largest drop on record https://www.japantimes.co.jp/news/2021/05/11/business/economy-business/household-spending-drop/ Household spending falls in fiscal second largest drop on recordSpending by households with two or more people averaged per month in the fiscal year through March decreasing for the second straight year 2021-05-12 01:09:47
海外ニュース Japan Times latest articles Toyota set to dodge earnings nightmare caused by chips crisis https://www.japantimes.co.jp/news/2021/05/11/business/corporate-business/toyota-chip-crisis/ global 2021-05-12 01:08:17
海外ニュース Japan Times latest articles Vissel captain Andres Iniesta extends contract through 2023 https://www.japantimes.co.jp/sports/2021/05/11/soccer/j-league/vissel-kobe-andres-iniesta-extension/ Vissel captain Andres Iniesta extends contract through The Spanish maestro who brought unprecedented attention to the J League when he arrived at Kobe in said he was excited to continue his 2021-05-12 01:30:56
海外ニュース Japan Times latest articles China makes us rethink capitalism https://www.japantimes.co.jp/opinion/2021/05/11/commentary/world-commentary/china-and-capitalism/ animal 2021-05-12 00:45:25
海外ニュース Japan Times latest articles Five things moms gained during COVID-19 — and should refuse to give up https://www.japantimes.co.jp/opinion/2021/05/11/commentary/world-commentary/womens-issues-five-things-moms-gained-during-covid-19/ Five things moms gained during COVID ー and should refuse to give upWhile the pandemic has brought many of us to the brink of our sanity it has also forced many organizations to give moms long overdue concessions 2021-05-12 00:33:47
ニュース BBC News - Home Ballymurphy Inquest: Coroner finds 10 victims were innocent https://www.bbc.co.uk/news/uk-northern-ireland-56986784 operation 2021-05-11 15:52:49
ニュース BBC News - Home Russia school shooting: Children and teacher killed in Kazan https://www.bbc.co.uk/news/world-europe-57069589 kazan 2021-05-11 15:50:26
ニュース BBC News - Home Fred West police search Gloucester cafe for Mary Bastholm https://www.bbc.co.uk/news/uk-england-gloucestershire-57070279 bastholm 2021-05-11 15:27:13
ニュース BBC News - Home Death toll mounts as Israel-Gaza violence escalates https://www.bbc.co.uk/news/world-middle-east-57066275 jerusalem 2021-05-11 15:30:01
ニュース BBC News - Home Giraffes return to Edinburgh Zoo after 15 years https://www.bbc.co.uk/news/uk-scotland-edinburgh-east-fife-57071464 bedfordshire 2021-05-11 15:42:10
ニュース BBC News - Home Uefa gives green light for 'limited number' of fans at Scottish Cup final https://www.bbc.co.uk/sport/football/57073714 hampden 2021-05-11 15:01:10
ビジネス ダイヤモンド・オンライン - 新着記事 中国、エリクソンに報復の構え ファーウェイ排除巡り最後通告 - WSJ発 https://diamond.jp/articles/-/270784 最後通告 2021-05-12 00:18:00
北海道 北海道新聞 早期接種へ支援要望相次ぐ コロナワクチンで道議会 https://www.hokkaido-np.co.jp/article/542748/ 新型コロナウイルス 2021-05-12 00:14:30

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)