Skip to main content

Posts

text tag not rendering inside a link tag

I want to use text tags inside svg as links but wrapping them inside an a tag seems to make them unable to render. here is the html <svg> <g fill="none" fill-rule="nonzero" stroke="#000100" stroke-width="none" stroke-linecap="round" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"> <path d="M409.5,319.17949l50,17.32051" fill="none" stroke-width="2"></path> <path d="M459.5,336.5l-77.79645,67.3737" fill="none" stroke-width="2"></path> <path d="M459.5,336.5l-77.79645,67.3737" fill="none" stroke-width="2"></path> <path d="M381.70355,403.8737l-25.11858,-

how to set CSS for MPDF in yii2 on generating pdf file

I am using yii2 basic and I need to generate a pdf report file which is styled with CSS file, I get the pdf well but CSS is not working on the generated file. Here is how I have implemented. in my controller.php file public function actionPrintReport($student_id,$exam_id,$total_subjects,$exam_date){ $model = new Results(); $examReportData = $model->getExamReport($student_id,$exam_id,$exam_date); $htmlContent = $this->renderPartial('_report', [ 'model' => $model, 'total_subjects' => $total_subjects, 'examReportData' => $examReportData ]); $pathfile = "Student_exam_report"; $mpdf = new \Mpdf\Mpdf([ 'tempDir' => Yii::getAlias('@runtime/') . 'mpdf2/tmp', 'format' => 'A4-L', 'margin_right' => 5,'margin_left' => 5, '

Git log with Python for showing old merged branches

I'm trying to create a script with list merged remote release branches which haven't had any updates in last 6 months, and then remove them. So far, I've been trying to do the list branches part with following script: import subprocess import subprocess import sys import git from git import Repo, repo from git import Git def get_merged_release_branches(): result_release = subprocess.getoutput("git branch -r --merged | grep release | sed 's#origin/##'") return (result_release) command = 'git log -1 --pretty=format:"%Cgreen%as" --before \\\'6 month ago' for branch in get_merged_release_branches(): output = subprocess.Popen(command, universal_newlines=True, shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() print(output) but that doesn´t seems to work. Getting black screen like iterating into something. Also not sure if with subprocess.popen is the best choice. What should be

Better understanding 'd' in d3.js with an example

I'm following this example in d3.js for how to make a small-multiple choropleth map: https://gist.github.com/armollica/6314f45890bcaaa45c808b5d2b0c602f There's this wrapper function: function ready(error, us, manufacturing) {} And within it, there is: function render(d) { var data = d.values; //this is the manufacturing data var context = d3.select(this).node().getContext("2d"); var color = function(d) { console.log(d) //this is the 'US' geography json data if (data.has(d.id)) { var value = data.get(d.id).pct_change_emp; return value ? colorScale(value) : "#fff"; } return "#fff"; }; // Want the maps to render sequentially. Use setTimeout to give the // browser a break in between drawing each map. window.setTimeout(function() { drawMap(context, color); }, 500); } I don't understand how the render function is accessing two different da

Should I prefer a function or an if-statement for any action

I have been coding a game for a while and I want to add the settings menu, the death menu and the victory menu. For making those menus visible, I thought about 2 different options: 1: game_loop(){ game(); document.resume_button.onclick = function(){"paused = false"}; document.pause_button.onclick = function(){"paused = true"}; if(!paused){ //if(!document.pauseMenu.visibility = "visible"){ //just an idea to prevent unnesecessary actions document.pauseMenu.visibility = "hidden"; //} }else{ //if(document.pauseMenu.visibility = "hidden"){ document.pauseMenu.visibility = "visible"; //} } } 2: game_loop(){ game(); document.resume_button.onclick = gameOver(0); document.pause_button.onclick = gameOver(1); } gameOver(x){ switch(x){ case 0: document.pauseMenu.visibility = "hidden"; break; case 1: document.pauseMenu.visibility = &quo

How do I render an MD file for a custom Storybook addon?

I am trying to render an MD file passed through parameters. I can successfully get the text to display, but I really want to get it formatted like an MD file. I was trying to use @storybook/addon-docs but it appears these need to be used in an MDX file instead of directly in React, as I am getting this error: Uncaught TypeError: storyById is not a function . import React from 'react'; import { useParameter } from '@storybook/api'; import { Title, Description } from '@storybook/addon-docs'; import { PARAM_KEY } from '../constants'; const WhatsNewPanel = (props: any) => { const value = useParameter(PARAM_KEY, null); const item = value ? value : 'No Markdown Defined'; return ( <> <Title>What&apos;s New?</Title> <Description>{item}</Description> </> ); }; export default WhatsNewPanel; If I remove the Title and Description components, I can see the unformatted MD text succe