python |
Pythonタグが付けられた新着投稿 - Qiita |
python-pptxで テキストの見た目を保持しつつ文字を変更する |
https://qiita.com/sugijotaro/items/ba5f0ae46a6a15372873
|
cmptinchesselfreplacetext |
2022-12-28 03:14:45 |
海外TECH |
DEV Community |
Salesforce Functions with Heroku Data for Redis |
https://dev.to/salesforcedevs/salesforce-functions-with-heroku-data-for-redis-4gj6
|
Salesforce Functions with Heroku Data for Redis Salesforce Functions and Heroku Data Series Part Two of ThreeThis article is part two of a three part series on using Heroku Managed Data products from within a Salesforce Function In part one we focused on Salesforce Functions with Heroku Postgres Here in part two we ll explore Salesforce Functions with Heroku Data for Redis Finally in part three we ll cover Salesforce Functions and Apache Kafka on Heroku Introduction to Core Concepts What is a Salesforce Function A Salesforce Function is a custom piece of code used to extend your Salesforce apps or processes The custom code can leverage the language and libraries you choose while being run in the secure environment of your Salesforce instance For example you could leverage a JavaScript library to calculate and cache a value based on a triggered process within Salesforce If you are new to Functions in general check out “Get to Know Salesforce Functions to learn about what they are and how they work What is Heroku Data for Redis Heroku Data for Redis is a Redis key value datastore that is fully managed for you by Heroku That means that Heroku takes care of things like security backups and maintenance All you need to do is use it Because Heroku is part of Salesforce this makes access and security much easier The Heroku Dev Center documentation is an excellent place to find more details on Heroku Data for Redis Examples of Salesforce Functions Heroku Data for RedisRedis is commonly used for ephemeral data that you want quick access to Examples include cached values a queue of tasks to be performed by workers session or state data for a process or users visiting a website While Redis can persist data to disk it is primarily used as an “in memory datastore Let s review several use cases to give you a better idea of how Salesforce Functions and Redis can fit together Use Case Store state between function runsThere may be times when a process has multiple stages with each stage requiring a function run When the next function runs you want to capture the state of that function run to be used by the next function that runs An example of this might be a price quoting process that requires some backend calculations at each stage Different people or teams might perform the steps in the process It s possible they don t even all belong within a single Salesforce Org However the function that runs at each stage needs to know about the previous outcome Use Case Managing a queue for worker processesThis use case is concerned with flexibility around background jobs Because applications built on Salesforce run on a multitenant architecture Salesforce places restrictions on CPU and memory usage for applications Long running programs are often out of bounds and restricted Then how might you run a long or heavy task for your Salesforce Org The answer is Salesforce Functions You can wire up your function to gather the information needed and insert it into Redis Then your Heroku worker processes can retrieve the information and perform the tasks Use Case Cache the results of expensive operationsIn this last use case let s assume that you have an expensive query or calculation The result does not change often but the report that needs the result runs frequently For example perhaps we want to match some criteria across a large number of records that seldom change We can use a Salesforce Function to do the work and Redis to store the result Subsequent executions of the function can simply grab the cached result How do I get started To get started you ll need to have a few pieces in placeーboth on the Salesforce Functions side and the Heroku side PrerequisitesAccess to Salesforce FunctionsAccess to Heroku Data servicesGetting started with Salesforce FunctionsGetting Started Accessing Heroku Data for Redis from a Salesforce FunctionOnce you have covered the prerequisites and created your project you can run the following commands to create a Function with Heroku Data for Redis access To create the new JavaScript Function run the following command sf generate function n yourfunction l javascriptThat will give you a functions folder with a Node js application template Connecting to your Redis instanceYour function code can use the dotenv package for specifying the Redis URL as an environment variable and the node redis package as a Redis client Connecting to Redis might look something like this import dotenv config import createClient from redis async function redisConnect const redis createClient url process env REDIS URL socket tls true rejectUnauthorized false await redis connect return redis For local execution using process env and dotenv assumes that you have a env file that specifies your REDIS URL Store data in RedisThe actual body of your Salesforce Function will involve performing some calculations or data fetches followed by storing the result in Redis An example may look like this export default async function event context const redis await redisConnect const CACHE KEY my cache key const CACHE TTL SECONDS Check Redis for cached value let cached value await redis get CACHE KEY if cached value return result cached value else Perform some calculation const calculated value await perform long running computation Store in Redis redis set CACHE KEY calculated value EX CACHE TTL SECONDS NX true Return result return result calculated value Test your Salesforce Function locallyTo test your Function locally you first run the following command sf run function startThen you can invoke the Function with a payload from another terminal sf run function l http localhost p payloadID info For more information on running Functions locally see this guide Associate your Salesforce Function and your Heroku environmentAfter verifying locally that our Function runs as expected we can associate our Saleseforce Function with a compute environment See this documentation for more information about how to create a compute environment and deploy a function Now associate your functions and Heroku environments by adding your Heroku user as a collaborator to your function s compute environment sf env compute collaborator add heroku user username example comThe environments can now share Heroku data Next you will need the name of the compute environment so that you can attach the datastore to it sf env listLastly attach the datastore heroku addons attach lt your heroku redis gt app lt your compute environment name gt Here are some additional resources that may be helpful for you as you begin implementing your Salesforce Function and accessing Heroku Data for Redis JavaScript Unit of Work exampleConnecting to Heroku Data for Redis from JavaScript ConclusionAnd just like that you re up and running with a Salesforce Function connecting to Heroku Data for Redis Salesforce Functions give you the flexibility and freedom to work within your Salesforce application to access Heroku dataーwhether that data is in Postgres Redis or even Kafka In this second part of our series we ve touched on using Salesforce Functions to work with Heroku Data for Redis While this is a fairly high level overview you should be able to see the potential of combining these two features In the final post for this series we ll integrate with Apache Kafka on Heroku |
2022-12-27 18:33:06 |
海外TECH |
DEV Community |
A philosophy of software design by John Ousterhout |
https://dev.to/zolletta/a-philosophy-of-software-design-by-john-ousterhout-4fpb
|
A philosophy of software design by John OusterhoutI recently came across this small less than pages and clever book which I found very interesting With the aim to make you buy your own copy I will tell you about this book focusing mainly on the complexity concept John Ousterhout is a professor of Computer Science at Stanford University He also invented TCL a “high level general purpose interpreted dynamic programming language in John decided to write this book because he found that the most demanding process in computer science is problem decomposition that is how can I split a complex problem into smaller manageable and developable parts Yet nobody teaches this skill everybody builds on that taking for granted that anybody can do that as an innate feature The author thinks that designing skills are what separates a great programmer from average ones His mantra emerging throughout his work is reduce complexity Ousterhout is also humble he knows very well that his book derives from his own opinions and that we might disagree with his view He invites us then to take his suggestions with a grain of salt I found this very refreshing there are a lot of books out there that provide us the real truth in every human field Complexity is everything that makes it hard to understand and modify the software Signs of complexity include Change amplification a supposed simple change requires a lot of updates in many different partsCognitive loads how much a developer needs to know to complete a task Unknown unknowns it is not clear what should be done in order to achieve our goalThe causes of complexity are either dependencies or obscurity We cannot really create a software system without adding some dependencies but our job is to make it explicit and reduce their number to a minimum Obscurity defined as anything that is not obvious or not consistent is clearly subjective So we cannot evaluate it by ourselves we need code reviews We should understand that complexity is an emergent quality It is something that accumulates by every little thing we skip to the next time Every little thing that we leave unresolved will settle creating a layer of dust into our system As the dust grows our system becomes dirt But when exactly it became dirt You cannot tell the real moment cleanness as complexity is a gradient And it has no end That s why there s a chapter called “working code isn t enough Tactical programming that is get those features as quickly as possible won t work in the long run This is how systems become complicated In order to avoid complexity we always need to keep in mind the long term structure of the system an approach the author defines as strategic programming We seldom create software from scratch nowadays instead we are almost always updating existing code So we should program in order to ease future code extensions this will ease our future developments A software system is composed of different abstraction layers Ideally methods directly implementing the interface should be at the highest level of abstraction and make use of lower ones in order to achieve their goals If we found ourselves up and down this lattice we might have a problem with class decomposition We might have a problem for instance when facing pass through methods from one class to another if they contribute no new functionality A dispatcher for instance is a pass through method but It has a reason to exists Decorators as per the author s point of view add seldom new functionalities and usually we can avoid them with other methodologies And how we can evict pass through variables Ousterhout suggests using a context object an object which will contain all the needed pass trough information without recurring to global state which is indeed bad Ousterhout suggests investing about of the time planned on a task to produce better software design This will make completing tasks slower but only in the first runs since once the complexity is reduced we can take advantage of that Side note This resembles the boy scout rule isn t it One advice the author gives us is to try to design every system twice trying to approach the problem from different standpoints No one gets it right at the first try ConclusionIn the whole book the author provides many examples to make clear his point of view it also gives programming advices besides complexity that are really worth reading so I hope you ll get the book |
2022-12-27 18:07:22 |
ニュース |
BBC News - Home |
Cody Fisher stabbed to death on Birmingham nightclub dance floor |
https://www.bbc.co.uk/news/uk-england-birmingham-64103150?at_medium=RSS&at_campaign=KARANGA
|
heart |
2022-12-27 18:40:49 |
ニュース |
BBC News - Home |
Russia bans oil sales to countries using price cap |
https://www.bbc.co.uk/news/world-europe-64102180?at_medium=RSS&at_campaign=KARANGA
|
ukraine |
2022-12-27 18:03:42 |
ニュース |
BBC News - Home |
Premiership: Harlequins 12-15 Bristol Bears - Bears hang on for brilliant win over Quins |
https://www.bbc.co.uk/sport/rugby-union/64070872?at_medium=RSS&at_campaign=KARANGA
|
Premiership Harlequins Bristol Bears Bears hang on for brilliant win over QuinsBristol Bears produce a gutsy defensive performance to beat Harlequins and move off the bottom of the Premiership table |
2022-12-27 18:27:56 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
女子校の「教育力」の源泉はどこにあるのか - 中学受験のキーパーソン |
https://diamond.jp/articles/-/314720
|
中学受験 |
2022-12-28 03:55:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
もし解雇されたら? 経験者に聞く - WSJ PickUp |
https://diamond.jp/articles/-/315229
|
wsjpickup |
2022-12-28 03:50:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
第2のAIG危機を防ぐために、保険の国際機関IAISが踏み切った「荒治療」の舞台裏 - きんざいOnline |
https://diamond.jp/articles/-/315292
|
その交渉は必ずしもゼロサムゲーム一方の得が他方の損ではなく、グローバルに価値ある基準を制定することが最大の目的である。 |
2022-12-28 03:45:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
アナリスト予想、利益は的中も株価は的外れ - WSJ PickUp |
https://diamond.jp/articles/-/315230
|
sampp |
2022-12-28 03:40:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
マスク氏「ハードコア」論争、米IT業界を揺らす - WSJ PickUp |
https://diamond.jp/articles/-/315231
|
wsjpickup |
2022-12-28 03:35:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
【大掃除したのになぜまた散らかるの?】「なぜか居心地の悪い家」に共通するたった1つの特徴 - 人生を変える断捨離 |
https://diamond.jp/articles/-/314421
|
第一人者 |
2022-12-28 03:30:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
「冷たくて、硬い体」は悲鳴をあげている。【整体プロがすすめる】血流が改善する超カンタンな方法 - すごい自力整体 |
https://diamond.jp/articles/-/315277
|
「自力整体」とは、人の手を借りずに、「整体施術のプロの技法」を自分におこなえるメソッド。 |
2022-12-28 03:25:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
何年働いてもお客様目線を持ち続けられる、たった1つの習慣 - 時間最短化、成果最大化の法則 |
https://diamond.jp/articles/-/314021
|
何年働いてもお客様目線を持ち続けられる、たったつの習慣時間最短化、成果最大化の法則【日経新聞掲載】有隣堂横浜駅西口店週間総合ベスト入り東洋経済オンライン「市場が評価した経営者ランキング」位、フォーブスアジア「アジアの優良中小企業ベスト」度受賞の著者が初めて明かす「最短時間で最大の成果を上げる方法」。 |
2022-12-28 03:20:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
「みんなと一緒が苦手」は本当にダメなことですか?【予約の取れないカウンセラーが教える】 - あなたはもう、自分のために生きていい |
https://diamond.jp/articles/-/315189
|
twitter |
2022-12-28 03:10:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
【その後のGE】伝説のCEOの死と続く悲劇 - GE帝国盛衰史 |
https://diamond.jp/articles/-/315265
|
追い打ち |
2022-12-28 03:05:00 |
コメント
コメントを投稿