Word Regular Expression Macro Messes with Formatting

regex
Question: I have created a MS Word macro that makes replacements from a .csv. The macro makes the replacements correctly, but it messes with the formatting. The document becomes entirely left-aligned and is made bold. Dim MyString As String Dim strArray() As String Open "example.csv" For Input As #1 Do While Not EOF(1) Line Input #1, MyString strArray = Split(MyString, ",") Dim re As Object Set re = CreateObject("vbscript.regexp") With re .MultiLine = False .Global = True .IgnoreCase = False .Pattern = "(W)" & (strArray(0)) & "(W)" End With Selection = re.Replace(Selection, "$1" & strArray(1) & "$2") Loop Close #1 Before I run the macro I select all the text. The document I have been testing with contains bold text. Thank you for any help. Answer: Read more
Read More

Angular2 app deployed in Liferay stuck at “Loading…” with Internet Explorer 11

Uncategorized
Question: I am trying to deploy my Angular IO app to Liferay platform with variable success. Mozilla Firefox and Google Chrome render the Liferay portlet without any troubles, but Internet Explorer 11 fails at it. To make matters even more bizarre, the app works fine with IE11 on localhost meaning that the polyfills.ts is working as expected. Answer: Read more
Read More

Spring data JPA batch insert is very slow

Uncategorized
Question: I am trying to read Excel file with 700K+ records and batch insert those in MySQL database table. Please note, Excel parsing is fast and I can get my entity objects in an ArrayList within 50 seconds or so. I am using Spring Boot and Spring Data JPA. Below is my partial application.properties file:hibernate.jdbc.batch_size=1000 spring.jpa.hibernate.use-new-id-generator-mappings=true and my partial Entity class:@Entity @Table(name = "WHT_APPS", schema = "TEST") public class WHTApps { @Id @TableGenerator(name = "whtAppsGen", table = "ID_GEN", pkColumnName = "GEN_KEY", valueColumnName = "GEN_VAL") @GeneratedValue(strategy = GenerationType.TABLE, generator = "whtAppsGen") private Long id; @Column(name = "VENDOR_CODE") private int vendorCode; . . . . Below is my DAO:@Repository @Transactional public class JapanWHTDaoImpl implements JapanWHTDao { @Autowired JapanWHTAppsRepository appsRepo; @Override public void storeApps(List whtAppsList) { appsRepo.save(whtAppsList); } and below is Repository class:@Transactional…
Read More

Synfony 3 doctrine show content from relationship on repo

Uncategorized
Question: I have to symfony entities SrvrsServers and NcBackupEvents:NCbrtBundle:SrvrsServers (id, name, description, etc) Relationship code:/** * One SrvrsServers has Many NcBackupEvents. * @ORMOneToMany(targetEntity="NcBackupEvents", mappedBy="SrvrsServers") */ private $ncBackupEvents; public function __construct() { $this->ncBackupEvents = new ArrayCollection(); } NCbrtBundle:NcBackupEvents (id, date, status, etc) This is on NcBackupEvents:/** * @var SrvrsServers * * @ORMManyToOne(targetEntity="SrvrsServers") * @ORMJoinColumns({ * @ORMJoinColumn(name="srvrs_servers_id", referencedColumnName="id") * }) */ private $srvrsServers; The relationship is one to many from SrvrsServers to NcBackupEvents. On the repo of NcBackupEvents am able to pull information about itself. This works and I think the SrvrsServers object get's pulled, but I am not 100% sure and also do not know how to access it:class NcBackupEventsRepository extends DoctrineORMEntityRepository { public function findByServerBackup($parameters) { $dql = 'SELECT n FROM NCbrtBundle:NcBackupEvents n WHERE n.backupmethod LIKE :backupmethod AND n.backupType LIKE…
Read More

Integral coefficient for internal energy of ionic liquid

Uncategorized
Question: I have a question, and I willbe really grateful if someone helps me. I have a polynomial equation for internal energy which I calculated by integration an equation of state formula, which is based on density. But, because I calculated this usong integration one integration constant which is temperature dependant( based on other article) that I don't know how can I formulate it to have its magnitude to calculate internal energy at other range of data. My simulation box has contained 200 molecule of ionic liquid with one negative ion( PF6) and a positive one( butyl metyl imidazolium). Because according to internal energy equation at zero density internal energy is equal to the integration constant, we considered it as as ionic liquid internal energy at ideal gas state. With…
Read More

Why canvas enlarge image size?

Uncategorized
Question: I want compress image that user upload on front side. source image is 651Kb(Mac OS), and after I change size form (1920 * 1080) to (1000 * 562), the size of picture becomes 1.2Mb(browser), 1.4Mb(Mac OS), 1.29Mb(Windows 7). whatever, it was increase the size of original image. Why? source image: http://7xoaqt.com1.z0.glb.clouddn.com/maikailun.jpg code: https://codepen.io/maicss/pen/ayLgdo/ const $ = document.querySelector.bind(document) const input = $('input') const canvas = $('canvas') const ctx = canvas.getContext('2d') const readableSize = (size) => { return size / 1024 > 1024 ? (~~(10 * size / 1024 / 1024)) / 10 + 'MB' : ~~(size / 1024) + 'KB' } input.onchange = function (e) { const files = e.target.files; [].forEach.call(files, file => { const img = new Image() img.src = URL.createObjectURL(file) img.onload = function () { let radio =…
Read More

Enable login to one device at a time

Uncategorized
Question: When user install the app, we generate unique id on the app and store it. User can login with user name and password. If login successful, server send OAuth token to app. App store the token and refresh tokens for future use. But when user try to login from new device, I want to logout the user from previous phone. How can I logout another device ? (I want to delete the OAuth tokens from previous device. if not app try to refresh the token and allow user to login.) Where I want to handle the logout logic ? Any help please. Answer: You can send a notification to the previously logged in device to remove the login. Or do a check in background every time the app starts,…
Read More

Like feedback using firebase crash. Fast click like-remove like

Uncategorized
Question: I have an application like instagram. It has feedback page. When user likes some post, I add this like and feedback (with its own key (.childByAutoId) for this like. static func add(_ newLike: LikeItem) { // add like id for user feedback implementation var like = newLike let likeRef = ref.child("/userslikes/" + newLike.userId + "/onposts/" + newLike.postId).childByAutoId() like.key = likeRef.key var updates: [String: Any?] = [ "/userslikes/" + like.userId + "/onposts/" + like.postId: like.toAnyObject(), "/postslikes/" + like.postId + "/" + like.userId: like.toAnyObject() ] if like.userId != like.postAddedByUserId { // dont add your own likes var likeForFeedBack = like.toAnyObject() likeForFeedBack["isViewed"] = false // when user will open feedback -> true updates.updateValue(likeForFeedBack, forKey: "/feedback/" + like.postAddedByUserId + "/" + like.key) } ref.updateChildValues(updates) } It's ok. And also I have remove function.…
Read More